libgit2sharp获取和包含之间的提交

时间:2017-02-03 23:57:04

标签: libgit2sharp

我使用带QueryBy的过滤器来获取我感兴趣的提交。

// Set the filter 
CommitFilter filter = null;
filter = new CommitFilter()
{
  IncludeReachableFrom = "85494c32921c136cc3381fc14a3a20e08012c514",
  ExcludeReachableFrom = "63c8cb9ed585c0f3b79b6e2efc067e254910f875"
};
// Get the commits
repo.Commits.QueryBy(filter) 

QueryBy不会返回63c8cb9ed585c0f3b79b6e2efc067e254910f875提交,它将返回两者之间的提交。

还有办法包含63c8cb9ed585c0f3b79b6e2efc067e254910f875提交吗?

也许还有另一种方法可用于从63c8cb9ed585c0f3b79b6e2efc067e254910f875之后的提交中获取之前的63c8cb9ed585c0f3b79b6e2efc067e254910f875并由查询返回?

1 个答案:

答案 0 :(得分:2)

您可以使用Commit作为ExcludeReachableFrom过滤器的提交指针列表。

实施例

    var filter = new CommitFilter
    {
        IncludeReachableFrom = "824201fcb8d4fa79b0aafa7c5aea86643cdd118a",
        ExcludeReachableFrom = repo.Lookup<Commit>("bcd85da0e287a3b404d12f8b666888962f692076").Parents
    };
    var commits = repo.Commits.QueryBy(filter);
    foreach (var commit in commits)
    {
        Console.WriteLine($"{commit.Sha}");
    }

输出:

824201fcb8d4fa79b0aafa7c5aea86643cdd118a
934fa3892acb2a48f296b7afc66b07125fb6db91
da995a21dc3fd038173695776fc1a3f4ff64f6ab
a9ee8086e5647141087c90909cd847a5fa5f294e
6313ca4b41dfef4d6b779f34f7b4807917c31188
bcd85da0e287a3b404d12f8b666888962f692076