我使用带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并由查询返回?
答案 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