Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions LibGit2Sharp.Tests/CommitFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void CanEnumerateCommitsFromSha()
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f" }))
foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f" }))
{
Assert.NotNull(commit);
count++;
Expand All @@ -107,9 +107,9 @@ public void QueryingTheCommitHistoryWithUnknownShaOrInvalidEntryPointThrows()
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Assert.Throws<NotFoundException>(() => repo.Commits.QueryBy(new CommitFilter { Since = Constants.UnknownSha }).Count());
Assert.Throws<NotFoundException>(() => repo.Commits.QueryBy(new CommitFilter { Since = "refs/heads/deadbeef" }).Count());
Assert.Throws<ArgumentNullException>(() => repo.Commits.QueryBy(new CommitFilter { Since = null }).Count());
Assert.Throws<NotFoundException>(() => repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = Constants.UnknownSha }).Count());
Assert.Throws<NotFoundException>(() => repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = "refs/heads/deadbeef" }).Count());
Assert.Throws<ArgumentNullException>(() => repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = null }).Count());
}
}

Expand All @@ -121,8 +121,8 @@ public void QueryingTheCommitHistoryFromACorruptedReferenceThrows()
{
CreateCorruptedDeadBeefHead(repo.Info.Path);

Assert.Throws<NotFoundException>(() => repo.Commits.QueryBy(new CommitFilter { Since = repo.Branches["deadbeef"] }).Count());
Assert.Throws<NotFoundException>(() => repo.Commits.QueryBy(new CommitFilter { Since = repo.Refs["refs/heads/deadbeef"] }).Count());
Assert.Throws<NotFoundException>(() => repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = repo.Branches["deadbeef"] }).Count());
Assert.Throws<NotFoundException>(() => repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = repo.Refs["refs/heads/deadbeef"] }).Count());
}
}

Expand All @@ -132,8 +132,8 @@ public void QueryingTheCommitHistoryWithBadParamsThrows()
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Assert.Throws<ArgumentException>(() => repo.Commits.QueryBy(new CommitFilter { Since = string.Empty }));
Assert.Throws<ArgumentNullException>(() => repo.Commits.QueryBy(new CommitFilter { Since = null }));
Assert.Throws<ArgumentException>(() => repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = string.Empty }));
Assert.Throws<ArgumentNullException>(() => repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = null }));
Assert.Throws<ArgumentNullException>(() => repo.Commits.QueryBy(default(CommitFilter)));
}
}
Expand All @@ -150,7 +150,7 @@ public void CanEnumerateCommitsWithReverseTimeSorting()
{
foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter
{
Since = "a4a7dce85cf63874e984719f4fdd239f5145052f",
IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f",
SortBy = CommitSortStrategies.Time | CommitSortStrategies.Reverse
}))
{
Expand All @@ -170,7 +170,7 @@ public void CanEnumerateCommitsWithReverseTopoSorting()
{
List<Commit> commits = repo.Commits.QueryBy(new CommitFilter
{
Since = "a4a7dce85cf63874e984719f4fdd239f5145052f",
IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f",
SortBy = CommitSortStrategies.Time | CommitSortStrategies.Reverse
}).ToList();
foreach (Commit commit in commits)
Expand All @@ -189,7 +189,7 @@ public void CanEnumerateCommitsWithReverseTopoSorting()
public void CanSimplifyByFirstParent()
{
AssertEnumerationOfCommits(
repo => new CommitFilter { Since = repo.Head, FirstParentOnly = true },
repo => new CommitFilter { IncludeReachableFrom = repo.Head, FirstParentOnly = true },
new[]
{
"4c062a6", "be3563a", "9fd738e",
Expand All @@ -216,7 +216,7 @@ public void CanEnumerateCommitsWithTimeSorting()
{
foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter
{
Since = "a4a7dce85cf63874e984719f4fdd239f5145052f",
IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f",
SortBy = CommitSortStrategies.Time
}))
{
Expand All @@ -236,7 +236,7 @@ public void CanEnumerateCommitsWithTopoSorting()
{
List<Commit> commits = repo.Commits.QueryBy(new CommitFilter
{
Since = "a4a7dce85cf63874e984719f4fdd239f5145052f",
IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f",
SortBy = CommitSortStrategies.Topological
}).ToList();
foreach (Commit commit in commits)
Expand All @@ -255,7 +255,7 @@ public void CanEnumerateCommitsWithTopoSorting()
public void CanEnumerateFromHead()
{
AssertEnumerationOfCommits(
repo => new CommitFilter { Since = repo.Head },
repo => new CommitFilter { IncludeReachableFrom = repo.Head },
new[]
{
"4c062a6", "be3563a", "c47800c", "9fd738e",
Expand All @@ -277,7 +277,7 @@ public void CanEnumerateFromDetachedHead()
repoClone.Checkout(headSha);

AssertEnumerationOfCommitsInRepo(repoClone,
repo => new CommitFilter { Since = repo.Head },
repo => new CommitFilter { IncludeReachableFrom = repo.Head },
new[]
{
"32eab9c", "592d3c8", "4c062a6",
Expand All @@ -291,7 +291,7 @@ public void CanEnumerateFromDetachedHead()
public void CanEnumerateUsingTwoHeadsAsBoundaries()
{
AssertEnumerationOfCommits(
repo => new CommitFilter { Since = "HEAD", Until = "refs/heads/br2" },
repo => new CommitFilter { IncludeReachableFrom = "HEAD", ExcludeReachableFrom = "refs/heads/br2" },
new[] { "4c062a6", "be3563a" }
);
}
Expand All @@ -300,7 +300,7 @@ public void CanEnumerateUsingTwoHeadsAsBoundaries()
public void CanEnumerateUsingImplicitHeadAsSinceBoundary()
{
AssertEnumerationOfCommits(
repo => new CommitFilter { Until = "refs/heads/br2" },
repo => new CommitFilter { ExcludeReachableFrom = "refs/heads/br2" },
new[] { "4c062a6", "be3563a" }
);
}
Expand All @@ -309,7 +309,7 @@ public void CanEnumerateUsingImplicitHeadAsSinceBoundary()
public void CanEnumerateUsingTwoAbbreviatedShasAsBoundaries()
{
AssertEnumerationOfCommits(
repo => new CommitFilter { Since = "a4a7dce", Until = "4a202b3" },
repo => new CommitFilter { IncludeReachableFrom = "a4a7dce", ExcludeReachableFrom = "4a202b3" },
new[] { "a4a7dce", "c47800c", "9fd738e" }
);
}
Expand All @@ -318,7 +318,7 @@ public void CanEnumerateUsingTwoAbbreviatedShasAsBoundaries()
public void CanEnumerateCommitsFromTwoHeads()
{
AssertEnumerationOfCommits(
repo => new CommitFilter { Since = new[] { "refs/heads/br2", "refs/heads/master" } },
repo => new CommitFilter { IncludeReachableFrom = new[] { "refs/heads/br2", "refs/heads/master" } },
new[]
{
"4c062a6", "a4a7dce", "be3563a", "c47800c",
Expand All @@ -330,7 +330,7 @@ public void CanEnumerateCommitsFromTwoHeads()
public void CanEnumerateCommitsFromMixedStartingPoints()
{
AssertEnumerationOfCommits(
repo => new CommitFilter { Since = new object[] { repo.Branches["br2"],
repo => new CommitFilter { IncludeReachableFrom = new object[] { repo.Branches["br2"],
"refs/heads/master",
new ObjectId("e90810b8df3e80c413d903f631643c716887138d") } },
new[]
Expand All @@ -345,7 +345,7 @@ public void CanEnumerateCommitsFromMixedStartingPoints()
public void CanEnumerateCommitsUsingGlob()
{
AssertEnumerationOfCommits(
repo => new CommitFilter { Since = repo.Refs.FromGlob("refs/heads/*") },
repo => new CommitFilter { IncludeReachableFrom = repo.Refs.FromGlob("refs/heads/*") },
new[]
{
"4c062a6", "e90810b", "6dcf9bf", "a4a7dce", "be3563a", "c47800c", "9fd738e", "4a202b3", "41bc8c6", "5001298", "5b5b025", "8496071"
Expand All @@ -356,7 +356,7 @@ public void CanEnumerateCommitsUsingGlob()
public void CanHideCommitsUsingGlob()
{
AssertEnumerationOfCommits(
repo => new CommitFilter { Since = "refs/heads/packed-test", Until = repo.Refs.FromGlob("*/packed") },
repo => new CommitFilter { IncludeReachableFrom = "refs/heads/packed-test", ExcludeReachableFrom = repo.Refs.FromGlob("*/packed") },
new[]
{
"4a202b3", "5b5b025", "8496071"
Expand All @@ -378,7 +378,7 @@ public void CanEnumerateCommitsFromATagAnnotation()
private void CanEnumerateCommitsFromATag(Func<Tag, object> transformer)
{
AssertEnumerationOfCommits(
repo => new CommitFilter { Since = transformer(repo.Tags["test"]) },
repo => new CommitFilter { IncludeReachableFrom = transformer(repo.Tags["test"]) },
new[] { "e90810b", "6dcf9bf", }
);
}
Expand All @@ -389,7 +389,7 @@ public void CanEnumerateAllCommits()
AssertEnumerationOfCommits(
repo => new CommitFilter
{
Since = repo.Refs.OrderBy(r => r.CanonicalName, StringComparer.Ordinal),
IncludeReachableFrom = repo.Refs.OrderBy(r => r.CanonicalName, StringComparer.Ordinal),
},
new[]
{
Expand All @@ -404,7 +404,7 @@ public void CanEnumerateAllCommits()
public void CanEnumerateCommitsFromATagWhichPointsToABlob()
{
AssertEnumerationOfCommits(
repo => new CommitFilter { Since = repo.Tags["point_to_blob"] },
repo => new CommitFilter { IncludeReachableFrom = repo.Tags["point_to_blob"] },
new string[] { });
}

Expand All @@ -419,7 +419,7 @@ public void CanEnumerateCommitsFromATagWhichPointsToATree()
Tag tag = repo.ApplyTag("point_to_tree", headTreeSha);

AssertEnumerationOfCommitsInRepo(repo,
r => new CommitFilter { Since = tag },
r => new CommitFilter { IncludeReachableFrom = tag },
new string[] { });
}
}
Expand Down Expand Up @@ -880,10 +880,10 @@ public void CanRetrieveChildrenOfASpecificCommit()
var filter = new CommitFilter
{
/* Revwalk from all the refs (git log --all) ... */
Since = repo.Refs,
IncludeReachableFrom = repo.Refs,

/* ... and stop when the parent is reached */
Until = parentSha
ExcludeReachableFrom = parentSha
};

var commits = repo.Commits.QueryBy(filter);
Expand Down
Loading