Adapt FindParentCommits() to return nothing when commits are not parents

This commit is contained in:
Philippe Miossec
2014-05-26 11:52:52 +02:00
committed by Philippe Miossec
parent f7ff64d3c3
commit bf301e6e30
+9 -1
View File
@@ -663,9 +663,17 @@ namespace Sep.Git.Tfs.Core
public IEnumerable<GitCommit> FindParentCommits(string @from, string to)
{
return _repository.Commits.QueryBy(
var commits = _repository.Commits.QueryBy(
new CommitFilter() {Since = @from, Until = to, SortBy = CommitSortStrategies.Reverse, FirstParentOnly = true})
.Select(c=>new GitCommit(c));
var parent = to;
foreach (var gitCommit in commits)
{
if(!gitCommit.Parents.Any(c=>c.Sha == parent))
return new List<GitCommit>();
parent = gitCommit.Sha;
}
return commits;
}
}
}