Permalink
Browse files

Check Since param if SinceGlob is not specified

  • Loading branch information...
1 parent b7dc4d3 commit aec0563dd13a73a2e2bacb4abddb4670e6e1d705 @tclem tclem committed Jun 21, 2012
Showing with 9 additions and 0 deletions.
  1. +3 −0 LibGit2Sharp.Tests/CommitFixture.cs
  2. +6 −0 LibGit2Sharp/CommitLog.cs
@@ -98,6 +98,7 @@ public void QueryingTheCommitHistoryWithUnknownShaOrInvalidEntryPointThrows()
{
Assert.Throws<LibGit2SharpException>(() => repo.Commits.QueryBy(new Filter { Since = Constants.UnknownSha }).Count());
Assert.Throws<LibGit2SharpException>(() => repo.Commits.QueryBy(new Filter { Since = "refs/heads/deadbeef" }).Count());
+ Assert.Throws<ArgumentNullException>(() => repo.Commits.QueryBy(new Filter { Since = null }).Count());
}
}
@@ -119,6 +120,8 @@ public void QueryingTheCommitHistoryWithBadParamsThrows()
{
using (var repo = new Repository(BareTestRepoPath))
{
+ Assert.Throws<ArgumentException>(() => repo.Commits.QueryBy(new Filter { Since = string.Empty }));
+ Assert.Throws<ArgumentNullException>(() => repo.Commits.QueryBy(new Filter { Since = null }));
Assert.Throws<ArgumentNullException>(() => repo.Commits.QueryBy(null));
}
}
@@ -87,6 +87,12 @@ public virtual ICommitLog QueryBy(Filter filter)
{
Ensure.ArgumentNotNull(filter, "filter");
+ if(string.IsNullOrEmpty(filter.SinceGlob))
+ {
+ Ensure.ArgumentNotNull(filter.Since, "filter.Since");
+ Ensure.ArgumentNotNullOrEmptyString(filter.Since.ToString(), "filter.Since");
+ }
+
return new CommitLog(repo, filter);
}

0 comments on commit aec0563

Please sign in to comment.