Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Libgit2sharp
提交
f48f5d11
L
Libgit2sharp
项目概览
jobily
/
Libgit2sharp
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
Libgit2sharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f48f5d11
编写于
12月 14, 2010
作者:
N
nulltoken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improved Repository.ApplyTag() error handling.
上级
48c6043b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
5 deletion
+37
-5
libgit2sharp.Tests/ApplyingATag.cs
libgit2sharp.Tests/ApplyingATag.cs
+15
-2
libgit2sharp/ObjectNotFoundException.cs
libgit2sharp/ObjectNotFoundException.cs
+8
-0
libgit2sharp/Repository.cs
libgit2sharp/Repository.cs
+13
-3
libgit2sharp/libgit2sharp.csproj
libgit2sharp/libgit2sharp.csproj
+1
-0
未找到文件。
libgit2sharp.Tests/ApplyingATag.cs
浏览文件 @
f48f5d11
...
...
@@ -6,16 +6,29 @@ namespace libgit2sharp.Tests
[
TestFixture
]
public
class
ApplyingATag
:
ReadWriteRepositoryFixtureBase
{
private
static
readonly
Signature
_signature
=
new
Signature
(
"me"
,
"me@me.me"
,
DateTimeOffset
.
Now
);
[
Test
]
public
void
ShouldThrowIfPassedANonExistingTarget
()
{
const
string
invalidTargetId
=
"deadbeef1b46c854b31185ea97743be6a8774479"
;
using
(
var
repo
=
new
Repository
(
PathToRepository
))
{
Assert
.
Throws
<
ObjectNotFoundException
>(()
=>
repo
.
ApplyTag
(
invalidTargetId
,
"tagged"
,
"messaged"
,
_signature
));
}
}
[
Test
]
public
void
ShouldWork
()
// TODO: Split into different tests (returnATag, PersistTheObject, MultipleApplies, ...)
{
const
string
targetId
=
"8496071c1b46c854b31185ea97743be6a8774479"
;
var
signature
=
new
Signature
(
"me"
,
"me@me.me"
,
DateTimeOffset
.
Now
);
Tag
appliedTag
;
using
(
var
repo
=
new
Repository
(
PathToRepository
))
{
appliedTag
=
repo
.
ApplyTag
(
targetId
,
"tagged"
,
"messaged"
,
signature
);
appliedTag
=
repo
.
ApplyTag
(
targetId
,
"tagged"
,
"messaged"
,
_
signature
);
}
var
target
=
appliedTag
.
Target
as
Commit
;
...
...
libgit2sharp/ObjectNotFoundException.cs
0 → 100644
浏览文件 @
f48f5d11
using
System
;
namespace
libgit2sharp
{
public
class
ObjectNotFoundException
:
Exception
{
}
}
\ No newline at end of file
libgit2sharp/Repository.cs
浏览文件 @
f48f5d11
...
...
@@ -101,9 +101,19 @@ public Tag ApplyTag(string targetId, string tagName, string tagMessage, Signatur
{
// TODO: To be refactored.
IntPtr
tag
;
OperationResult
t
=
LibGit2Api
.
wrapped_git_apply_tag
(
out
tag
,
_lifecycleManager
.
RepositoryPtr
,
targetId
,
tagName
,
tagMessage
,
signature
.
Name
,
signature
.
Email
,
(
ulong
)((
GitDate
)
signature
.
When
).
UnixTimeStamp
);
return
(
Tag
)
_builder
.
BuildFrom
(
tag
,
ObjectType
.
Tag
);
OperationResult
result
=
LibGit2Api
.
wrapped_git_apply_tag
(
out
tag
,
_lifecycleManager
.
RepositoryPtr
,
targetId
,
tagName
,
tagMessage
,
signature
.
Name
,
signature
.
Email
,
(
ulong
)((
GitDate
)
signature
.
When
).
UnixTimeStamp
);
switch
(
result
)
{
case
OperationResult
.
GIT_SUCCESS
:
return
(
Tag
)
_builder
.
BuildFrom
(
tag
,
ObjectType
.
Tag
);
case
OperationResult
.
GIT_ENOTFOUND
:
throw
new
ObjectNotFoundException
();
default
:
throw
new
Exception
(
Enum
.
GetName
(
typeof
(
OperationResult
),
result
));
}
}
}
}
\ No newline at end of file
libgit2sharp/libgit2sharp.csproj
浏览文件 @
f48f5d11
...
...
@@ -49,6 +49,7 @@
<Compile
Include=
"IResolver.cs"
/>
<Compile
Include=
"NotAValidRepositoryException.cs"
/>
<Compile
Include=
"ObjectId.cs"
/>
<Compile
Include=
"ObjectNotFoundException.cs"
/>
<Compile
Include=
"ObjectResolver.cs"
/>
<Compile
Include=
"RepositoryLifecycleManager.cs"
/>
<Compile
Include=
"Signature.cs"
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录