8000 Fix issue when enumerating commits · MicrosoftWebMatrix/libgit2sharp@c001385 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit c001385

Browse files
committed
Fix issue when enumerating commits
When not explicitly set, the "Since" boundary should be "HEAD".
1 parent dfb856c commit c001385

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

LibGit2Sharp.Tests/CommitFixture.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,22 @@ public void CanEnumerateUsingTwoHeadsAsBoundaries()
174174
{
175175
using (var repo = new Repository(Constants.BareTestRepoPath))
176176
{
177-
var commits = repo.Commits.QueryBy(new Filter { Since = "refs/heads/br2", Until = "refs/heads/packed-test" });
177+
var commits = repo.Commits.QueryBy(new Filter { Since = "HEAD", Until = "refs/heads/br2" });
178178

179179
IEnumerable<string> abbrevShas = commits.Select(c => c.Id.ToString(7)).ToArray();
180-
CollectionAssert.AreEquivalent(new[] { "a4a7dce", "c47800c", "9fd738e" }, abbrevShas);
180+
CollectionAssert.AreEquivalent(new[] { "4c062a6", "be3563a" }, abbrevShas);
181+
}
182+
}
183+
184+
[Test]
185+
public void CanEnumerateUsingOneHeadAsBoundaries()
186+
{
187+
using (var repo = new Repository(Constants.BareTestRepoPath))
188+
{
189+
var commits = repo.Commits.QueryBy(new Filter { Until = "refs/heads/br2" });
190+
191+
IEnumerable<string> abbrevShas = commits.Select(c => c.Id.ToString(7)).ToArray();
192+
CollectionAssert.AreEquivalent(new[] { "4c062a6", "be3563a" }, abbrevShas);
181193
}
182194
}
183195

@@ -192,7 +204,7 @@ public void CanEnumerateUsingTwoAbbreviatedShasAsBoundaries()
192204
CollectionAssert.AreEquivalent(new[] { "a4a7dce", "c47800c", "9fd738e" }, abbrevShas);
193205
}
194206
}
195-
207+
196208
[Test]
197209
public void CanLookupCommitGeneric()
198210
{

LibGit2Sharp/Filter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class Filter
1111
public Filter()
1212
{
1313
SortBy = GitSortOptions.Time;
14+
Since = "HEAD";
1415
}
1516

1617
/// <summary>

0 commit comments

Comments
 (0)
0