2015-02-05 2 views
4

LibGit2Sharp를 사용하여 지정된 커밋 이후 모든 커밋을 가져올 수 있습니까?LibGit2Sharp {Hash} 이후로 모든 커밋 받기

나는 다음 시도했다 .. 그러나 그것은 작동하지 않았다 :

using (var repo = new Repository(repositoryDirectory)) 
{ 
    //Create commit filter. 
    var filter = new CommitFilter 
    { 
     SortBy = CommitSortStrategies.Topological | CommitSortStrategies.Reverse, 
     Since = repo.Refs 
    }; 

    /*Not Working 
    if (shaHashOfCommit.IsNotEmpty()) 
     filter.Since = shaHashOfCommit; 
    */ 

    var commits = repo.Commits.QueryBy(filter); 
} 

답변

5

코드는 아래의 기대를 충족해야한다.

using (var repo = new Repository(repositoryDirectory)) 
{ 
    var c = repo.Lookup<Commit>(shaHashOfCommit); 

    // Let's only consider the refs that lead to this commit... 
    var refs = repo.Refs.ReachableFrom(new []{c}); 

    //...and create a filter that will retrieve all the commits... 
    var cf = new CommitFilter 
    { 
     Since = refs,  // ...reachable from all those refs... 
     Until = c   // ...until this commit is met 
    }; 

    var cs = repo.Commits.QueryBy(cf); 

    foreach (var co in cs) 
    { 
     Console.WriteLine("{0}: {1}", co.Id.ToString(7), co.MessageShort); 
    }  
} 
+0

고맙습니다 .. 솔루션이 완벽하게 작동했습니다. – musium

관련 문제