summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Aniszczyk <caniszczyk@gmail.com>2010-11-08 07:50:43 -0500
committerCode Review <codereview-daemon@eclipse.org>2010-11-08 07:50:43 -0500
commit5dc72352f5e7d8d5dcccce5cde7b7c9273b1385a (patch)
tree19d6b502e2c7478021f0a5301b4a8ce5a737521b
parentd6fec1988c306333f5638bd2f35895d732b31e73 (diff)
parentaf31a97c82eb1a213fbc853daf9e9cab68bceccb (diff)
downloadjgit-5dc72352f5e7d8d5dcccce5cde7b7c9273b1385a.tar.gz
jgit-5dc72352f5e7d8d5dcccce5cde7b7c9273b1385a.zip
Merge "CommitAndLogCommandTests: add a test for LogCommand.addRange()"
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java
index 9106cc2c04..3d7f77972e 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java
@@ -53,6 +53,8 @@ import org.eclipse.jgit.api.errors.NoFilepatternException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.api.errors.NoMessageException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
+import org.eclipse.jgit.errors.IncorrectObjectTypeException;
+import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.UnmergedPathException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
@@ -105,6 +107,7 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
git.commit().setAuthor(author).call();
fail("Didn't get the expected exception");
} catch (NoMessageException e) {
+ // expected
}
}
@@ -122,6 +125,7 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
commitCmd.setAuthor(author);
fail("didn't catch the expected exception");
} catch (IllegalStateException e) {
+ // expected
}
LogCommand logCmd = git.log();
logCmd.call();
@@ -130,6 +134,7 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
logCmd.call();
fail("didn't catch the expected exception");
} catch (IllegalStateException e) {
+ // expected
}
}
@@ -191,4 +196,39 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
assertEquals("db00fd65b218578127ea51f3dffac701f12f486a",
tw.getObjectId(0).getName());
}
+
+ public void testCommitRange() throws NoHeadException, NoMessageException,
+ UnmergedPathException, ConcurrentRefUpdateException,
+ JGitInternalException, WrongRepositoryStateException,
+ IncorrectObjectTypeException, MissingObjectException {
+ // do 4 commits and set the range to the second and fourth one
+ Git git = new Git(db);
+ git.commit().setMessage("first commit").call();
+ RevCommit second = git.commit().setMessage("second commit")
+ .setCommitter(committer).call();
+ git.commit().setMessage("third commit").setAuthor(author).call();
+ RevCommit last = git.commit().setMessage("fourth commit").setAuthor(
+ author)
+ .setCommitter(committer).call();
+ Iterable<RevCommit> commits = git.log().addRange(second.getId(),
+ last.getId()).call();
+
+ // check that we have the third and fourth commit
+ PersonIdent defaultCommitter = new PersonIdent(db);
+ PersonIdent expectedAuthors[] = new PersonIdent[] { author, author };
+ PersonIdent expectedCommitters[] = new PersonIdent[] {
+ defaultCommitter, committer };
+ String expectedMessages[] = new String[] { "third commit",
+ "fourth commit" };
+ int l = expectedAuthors.length - 1;
+ for (RevCommit c : commits) {
+ assertEquals(expectedAuthors[l].getName(), c.getAuthorIdent()
+ .getName());
+ assertEquals(expectedCommitters[l].getName(), c.getCommitterIdent()
+ .getName());
+ assertEquals(c.getFullMessage(), expectedMessages[l]);
+ l--;
+ }
+ assertEquals(l, -1);
+ }
}