Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Libgit2sharp
提交
1e6db85f
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,发现更多精彩内容 >>
提交
1e6db85f
编写于
12月 13, 2010
作者:
N
nulltoken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added first draft implementation of Tag applying.
上级
35a3eb48
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
89 addition
and
14 deletion
+89
-14
libgit2sharp.Tests/ApplyingATag.cs
libgit2sharp.Tests/ApplyingATag.cs
+31
-0
libgit2sharp.Tests/libgit2sharp.Tests.csproj
libgit2sharp.Tests/libgit2sharp.Tests.csproj
+3
-0
libgit2sharp/Repository.cs
libgit2sharp/Repository.cs
+15
-0
libgit2sharp/Wrapper/LibGit2Api.cs
libgit2sharp/Wrapper/LibGit2Api.cs
+4
-0
libgit2wrap/src/libgit2wrap.c
libgit2wrap/src/libgit2wrap.c
+34
-0
libgit2wrap/src/libgit2wrap.h
libgit2wrap/src/libgit2wrap.h
+2
-14
未找到文件。
libgit2sharp.Tests/ApplyingATag.cs
0 → 100644
浏览文件 @
1e6db85f
using
System
;
using
NUnit.Framework
;
namespace
libgit2sharp.Tests
{
[
TestFixture
]
public
class
ApplyingATag
:
ReadWriteRepositoryFixtureBase
{
[
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
);
}
Tag
retrievedTag
;
using
(
var
repo
=
new
Repository
(
PathToRepository
))
{
retrievedTag
=
repo
.
Resolve
<
Tag
>(
appliedTag
.
Id
);
}
Assert
.
AreEqual
(
appliedTag
.
Id
,
retrievedTag
.
Id
);
// TODO: Finalize comparison
}
}
}
\ No newline at end of file
libgit2sharp.Tests/libgit2sharp.Tests.csproj
浏览文件 @
1e6db85f
...
...
@@ -43,6 +43,9 @@
<Reference
Include=
"System.Xml"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"ApplyingATag.cs"
>
<SubType>
Code
</SubType>
</Compile>
<Compile
Include=
"GitDateFixture.cs"
/>
<Compile
Include=
"ObjectIdFixture.cs"
/>
<Compile
Include=
"ReadOnlyRepositoryFixtureBase.cs"
/>
...
...
libgit2sharp/Repository.cs
浏览文件 @
1e6db85f
...
...
@@ -90,5 +90,20 @@ public object Resolve(string objectId, Type expectedType)
{
return
_resolver
.
Resolve
(
objectId
,
expectedType
);
}
public
Tag
ApplyTag
(
string
targetId
,
string
tagName
,
string
tagMessage
,
Signature
signature
)
{
// 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
)
BuildTag
(
tag
);
}
private
static
object
BuildTag
(
IntPtr
gitObjectPtr
)
{
// TODO: Duplicated from ObjectResolver
var
gitTag
=
(
git_tag
)
Marshal
.
PtrToStructure
(
gitObjectPtr
,
typeof
(
git_tag
));
return
gitTag
.
Build
();
}
}
}
\ No newline at end of file
libgit2sharp/Wrapper/LibGit2Api.cs
浏览文件 @
1e6db85f
...
...
@@ -27,5 +27,9 @@ internal static class LibGit2Api
[
DllImport
(
Libgit2
)]
public
static
extern
OperationResult
wrapped_git_odb_read
(
out
git_rawobj
rawObject
,
[
In
]
IntPtr
repository
,
[
In
]
string
objectId
);
[
DllImport
(
Libgit2
)]
// TODO: Try to use a git_person struct
public
static
extern
OperationResult
wrapped_git_apply_tag
(
out
IntPtr
tagPtr
,
[
In
]
IntPtr
repository
,
[
In
]
string
targetId
,
[
In
]
string
tagName
,
[
In
]
string
tagMessage
,
[
In
]
string
taggerName
,
[
In
]
string
taggerEmail
,
ulong
taggerTime
);
}
}
\ No newline at end of file
libgit2wrap/src/libgit2wrap.c
浏览文件 @
1e6db85f
...
...
@@ -99,5 +99,39 @@ int wrapped_git_odb_read(git_rawobj* obj_out, git_repository* repo, const char *
if
(
error
!=
GIT_SUCCESS
)
return
error
;
return
error
;
}
int
wrapped_git_apply_tag
(
git_tag
**
tag_out
,
git_repository
*
repo
,
const
char
*
raw_target_id
,
const
char
*
tag_name
,
const
char
*
tag_message
,
const
char
*
tagger_name
,
const
char
*
tagger_email
,
time_t
tagger_time
)
{
git_oid
id
;
int
error
;
git_object
*
target
;
git_tag
*
tag
;
error
=
git_oid_mkstr
(
&
id
,
raw_target_id
);
if
(
error
!=
GIT_SUCCESS
)
return
error
;
error
=
git_repository_lookup
(
&
target
,
repo
,
&
id
,
GIT_OBJ_ANY
);
if
(
error
!=
GIT_SUCCESS
)
return
error
;
error
=
git_tag_new
(
&
tag
,
repo
);
if
(
error
!=
GIT_SUCCESS
)
return
error
;
git_tag_set_tagger
(
tag
,
tagger_name
,
tagger_email
,
tagger_time
);
git_tag_set_name
(
tag
,
tag_name
);
git_tag_set_target
(
tag
,
target
);
git_tag_set_message
(
tag
,
tag_message
);
error
=
git_object_write
((
git_object
*
)
tag
);
if
(
error
!=
GIT_SUCCESS
)
return
error
;
*
tag_out
=
tag
;
return
error
;
}
\ No newline at end of file
libgit2wrap/src/libgit2wrap.h
浏览文件 @
1e6db85f
...
...
@@ -3,19 +3,6 @@
#include <git2.h>
typedef
struct
wrapped_git_repository
{
size_t
db
;
size_t
index
;
size_t
objects
;
char
*
path_repository
;
char
*
path_index
;
char
*
path_odb
;
char
*
path_workdir
;
unsigned
is_bare
:
1
;
}
wrapped_git_repository
;
GIT_BEGIN_DECL
GIT_EXTERN
(
int
)
wrapped_git_repository_open
(
git_repository
**
repo_out
,
const
char
*
path
);
...
...
@@ -24,7 +11,8 @@ GIT_EXTERN(void) wrapped_git_repository_free(git_repository* repo);
GIT_EXTERN
(
int
)
wrapped_git_repository_lookup
(
git_object
**
obj_out
,
git_repository
*
repo
,
const
char
*
raw_id
,
git_otype
type
);
GIT_EXTERN
(
int
)
wrapped_git_odb_exists
(
git_repository
*
repo
,
const
char
*
raw_id
);
GIT_EXTERN
(
int
)
wrapped_git_odb_read_header
(
git_rawobj
*
obj_out
,
git_repository
*
repo
,
const
char
*
raw_id
);
GIT_EXTERN
(
int
)
wrapped_git_odb_read
(
git_rawobj
*
obj_out
,
git_repository
*
repo
,
const
char
*
raw_id
);
GIT_EXTERN
(
int
)
wrapped_git_odb_read
(
git_rawobj
**
obj_out
,
git_repository
*
repo
,
const
char
*
raw_id
);
GIT_EXTERN
(
int
)
wrapped_git_apply_tag
(
git_tag
*
tag_out
,
git_repository
*
repo
,
const
char
*
raw_target_id
,
const
char
*
tag_name
,
const
char
*
tag_message
,
const
char
*
tagger_name
,
const
char
*
tagger_email
,
time_t
tagger_time
);
GIT_END_DECL
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录