2017-04-18 84 views
0

我们一个Git bash命令给出低于该得到的承诺文件在github上2个标签的列表之间的文件列表,Libgit2Sharp:获得两个标签

git log tag1 tag2 --stat 

谁能为它提供了相当于Libgit2Sharp码?

回答

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(); 
     }