summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorTomasz Zarna2012-11-01 19:36:55 (EDT)
committer Chris Aniszczyk2012-11-01 19:56:30 (EDT)
commit908d219dbd2c19985b0834539075d33164e9f276 (patch)
treed8c1cd863a3211a2b6e80b2e2f73f2167e8aa630
parentde2455af678b5c9d0111336daed1ca0e0958ca01 (diff)
downloadjgit-908d219dbd2c19985b0834539075d33164e9f276.zip
jgit-908d219dbd2c19985b0834539075d33164e9f276.tar.gz
jgit-908d219dbd2c19985b0834539075d33164e9f276.tar.bz2
Add ReflogCommandTest#testAmendReflogrefs/changes/80/8480/3
Add a test for reflog with an amend commit and add assertions for branch comments Change-Id: Ie44076ff1abf1f8954b85d8c74ac6cb41ab789cb Signed-off-by: Chris Aniszczyk <zx@twitter.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ReflogCommandTest.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ReflogCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ReflogCommandTest.java
index 78123d8..1502436 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ReflogCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ReflogCommandTest.java
@@ -93,6 +93,8 @@ public class ReflogCommandTest extends RepositoryTestCase {
assertEquals(reflogs[2].getComment(), "commit: Initial commit");
assertEquals(reflogs[2].getNewId(), commit1.getId());
assertEquals(reflogs[2].getOldId(), ObjectId.zeroId());
+ assertEquals(reflogs[1].getComment(),
+ "checkout: moving from master to b1");
assertEquals(reflogs[1].getNewId(), commit1.getId());
assertEquals(reflogs[1].getOldId(), commit1.getId());
assertEquals(reflogs[0].getComment(), "commit: Removed file");
@@ -115,7 +117,37 @@ public class ReflogCommandTest extends RepositoryTestCase {
assertEquals(reflogs[0].getComment(), "commit: Removed file");
assertEquals(reflogs[0].getNewId(), commit2.getId());
assertEquals(reflogs[0].getOldId(), commit1.getId());
+ assertEquals(reflogs[1].getComment(),
+ "branch: Created from commit Initial commit");
assertEquals(reflogs[1].getNewId(), commit1.getId());
assertEquals(reflogs[1].getOldId(), ObjectId.zeroId());
}
+
+ /**
+ * Test getting the reflog for an amend commit
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testAmendReflog() throws Exception {
+ RevCommit commit2a = git.commit().setAmend(true)
+ .setMessage("Deleted file").call();
+ Collection<ReflogEntry> reflog = git.reflog().call();
+ assertNotNull(reflog);
+ assertEquals(4, reflog.size());
+ ReflogEntry[] reflogs = reflog.toArray(new ReflogEntry[reflog.size()]);
+ assertEquals(reflogs[3].getComment(), "commit: Initial commit");
+ assertEquals(reflogs[3].getNewId(), commit1.getId());
+ assertEquals(reflogs[3].getOldId(), ObjectId.zeroId());
+ assertEquals(reflogs[2].getComment(),
+ "checkout: moving from master to b1");
+ assertEquals(reflogs[2].getNewId(), commit1.getId());
+ assertEquals(reflogs[2].getOldId(), commit1.getId());
+ assertEquals(reflogs[1].getComment(), "commit: Removed file");
+ assertEquals(reflogs[1].getNewId(), commit2.getId());
+ assertEquals(reflogs[1].getOldId(), commit1.getId());
+ assertEquals(reflogs[0].getComment(), "commit (amend): Deleted file");
+ assertEquals(reflogs[0].getNewId(), commit2a.getId());
+ assertEquals(reflogs[0].getOldId(), commit2.getId());
+ }
}