我们在下面给出了一个Git bash命令,它获取github中2个标签之间的已提交文件列表,
git log tag1 tag2 --stat
有人能为它提供等效的Libgit2Sharp代码吗?
答案 0 :(得分:0)
试试这个:git log tag1 tag2 --stat
using (var repo = new Repository(@"repoPath"))
{
Tag tagTo = repo.Tags["tag2"];
Tag tagFrom = repo.Tags["tag1"];
var commitFrom = repo.Lookup<LibGit2Sharp.Commit>(tagFrom.Target.Sha);
var commitTo = repo.Lookup<LibGit2Sharp.Commit>(tagTo.Target.Sha);
TreeChanges treeChanges = repo.Diff.Compare<TreeChanges>(commitFrom.Tree, commitTo.Tree);
}
但是当你只想在标签之间提交时:git log tag1 tag2
你可以使用:
using (var repo = new Repository(@"repoPath"))
{
Tag tagTo = repo.Tags["tag2"];
Tag tagFrom = repo.Tags["tag1"];
var filter = new CommitFilter();
filter.IncludeReachableFrom = tagTo.Target.Sha;
filter.ExcludeReachableFrom = tagFrom.Target.Sha;
var commits = repo.Commits.QueryBy(filter).ToList();
}