diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2011-09-08 19:42:19 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2011-09-21 23:36:55 +0200 |
commit | ad50a0b7c017b6e06614aae151ffefdc0f26ea29 (patch) | |
tree | 161af931d7c1cd0f9db43573a8b524f3e784583b /org.eclipse.jgit.test/tst/org | |
parent | 39ad503fcb0c293e9c6d47d653a0d52456d4760b (diff) | |
download | jgit-ad50a0b7c017b6e06614aae151ffefdc0f26ea29.tar.gz jgit-ad50a0b7c017b6e06614aae151ffefdc0f26ea29.zip |
Test the reflog message for commit, cherry-pick, revert and merge
Change-Id: I319f09577b3e04f6c31399fe8e57e9a9ad2c8a6c
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org')
4 files changed, 61 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CherryPickCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CherryPickCommandTest.java index 94af81e812..9f92c045c0 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CherryPickCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CherryPickCommandTest.java @@ -59,6 +59,7 @@ import org.eclipse.jgit.lib.RepositoryState; import org.eclipse.jgit.lib.RepositoryTestCase; import org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason; import org.eclipse.jgit.revwalk.RevCommit; +import org.eclipse.jgit.storage.file.ReflogReader; import org.junit.Test; /** @@ -223,5 +224,14 @@ public class CherryPickCommandTest extends RepositoryTestCase { // index shall be unchanged assertEquals(indexState, indexState(CONTENT)); assertEquals(RepositoryState.SAFE, db.getRepositoryState()); + + if (reason == null) { + ReflogReader reader = db.getReflogReader(Constants.HEAD); + assertTrue(reader.getLastEntry().getComment() + .startsWith("cherry-pick: ")); + reader = db.getReflogReader(db.getBranch()); + assertTrue(reader.getLastEntry().getComment() + .startsWith("cherry-pick: ")); + } } } 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 fa97198d8c..aac1dc1496 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 @@ -109,6 +109,8 @@ public class CommitAndLogCommandTests extends RepositoryTestCase { assertEquals(l, -1); ReflogReader reader = db.getReflogReader(Constants.HEAD); assertTrue(reader.getLastEntry().getComment().startsWith("commit:")); + reader = db.getReflogReader(db.getBranch()); + assertTrue(reader.getLastEntry().getComment().startsWith("commit:")); } @Test @@ -318,6 +320,9 @@ public class CommitAndLogCommandTests extends RepositoryTestCase { ReflogReader reader = db.getReflogReader(Constants.HEAD); assertTrue(reader.getLastEntry().getComment() .startsWith("commit (amend):")); + reader = db.getReflogReader(db.getBranch()); + assertTrue(reader.getLastEntry().getComment() + .startsWith("commit (amend):")); } @Test diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java index 1c682cae10..bb90588918 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java @@ -80,6 +80,13 @@ public class MergeCommandTest extends RepositoryTestCase { MergeResult result = git.merge().include(db.getRef(Constants.HEAD)).call(); assertEquals(MergeResult.MergeStatus.ALREADY_UP_TO_DATE, result.getMergeStatus()); + // no reflog entry written by merge + assertEquals("commit: initial commit", + db + .getReflogReader(Constants.HEAD).getLastEntry().getComment()); + assertEquals("commit: initial commit", + db + .getReflogReader(db.getBranch()).getLastEntry().getComment()); } @Test @@ -92,7 +99,11 @@ public class MergeCommandTest extends RepositoryTestCase { MergeResult result = git.merge().include(db.getRef("refs/heads/branch1")).call(); assertEquals(MergeResult.MergeStatus.ALREADY_UP_TO_DATE, result.getMergeStatus()); assertEquals(second, result.getNewHead()); - + // no reflog entry written by merge + assertEquals("commit: second commit", db + .getReflogReader(Constants.HEAD).getLastEntry().getComment()); + assertEquals("commit: second commit", db + .getReflogReader(db.getBranch()).getLastEntry().getComment()); } @Test @@ -109,6 +120,10 @@ public class MergeCommandTest extends RepositoryTestCase { assertEquals(MergeResult.MergeStatus.FAST_FORWARD, result.getMergeStatus()); assertEquals(second, result.getNewHead()); + assertEquals("merge refs/heads/master: Fast-forward", + db.getReflogReader(Constants.HEAD).getLastEntry().getComment()); + assertEquals("merge refs/heads/master: Fast-forward", + db.getReflogReader(db.getBranch()).getLastEntry().getComment()); } @Test @@ -136,6 +151,10 @@ public class MergeCommandTest extends RepositoryTestCase { assertTrue(new File(db.getWorkTree(), "file2").exists()); assertEquals(MergeResult.MergeStatus.FAST_FORWARD, result.getMergeStatus()); assertEquals(second, result.getNewHead()); + assertEquals("merge refs/heads/master: Fast-forward", + db.getReflogReader(Constants.HEAD).getLastEntry().getComment()); + assertEquals("merge refs/heads/master: Fast-forward", + db.getReflogReader(db.getBranch()).getLastEntry().getComment()); } @Test @@ -190,6 +209,14 @@ public class MergeCommandTest extends RepositoryTestCase { MergeResult result = git.merge().setStrategy(mergeStrategy) .include(db.getRef(Constants.MASTER)).call(); assertEquals(MergeStatus.MERGED, result.getMergeStatus()); + assertEquals( + "merge refs/heads/master: Merge made by " + + mergeStrategy.getName() + ".", + db.getReflogReader(Constants.HEAD).getLastEntry().getComment()); + assertEquals( + "merge refs/heads/master: Merge made by " + + mergeStrategy.getName() + ".", + db.getReflogReader(db.getBranch()).getLastEntry().getComment()); } @Test @@ -370,6 +397,14 @@ public class MergeCommandTest extends RepositoryTestCase { .setStrategy(MergeStrategy.RESOLVE).call(); assertEquals(MergeStatus.MERGED, result.getMergeStatus()); assertEquals("1\nb(1)\n3\n", read(new File(db.getWorkTree(), "b"))); + assertEquals("merge " + secondCommit.getId().getName() + + ": Merge made by resolve.", db + .getReflogReader(Constants.HEAD) + .getLastEntry().getComment()); + assertEquals("merge " + secondCommit.getId().getName() + + ": Merge made by resolve.", db + .getReflogReader(db.getBranch()) + .getLastEntry().getComment()); } @Test diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RevertCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RevertCommandTest.java index 38e7af50fa..11cef635af 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RevertCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RevertCommandTest.java @@ -50,8 +50,10 @@ import java.util.Iterator; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.JGitInternalException; +import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.RepositoryTestCase; import org.eclipse.jgit.revwalk.RevCommit; +import org.eclipse.jgit.storage.file.ReflogReader; import org.junit.Test; /** @@ -100,5 +102,13 @@ public class RevertCommandTest extends RepositoryTestCase { assertEquals("create b", history.next().getFullMessage()); assertEquals("create a", history.next().getFullMessage()); assertFalse(history.hasNext()); + + ReflogReader reader = db.getReflogReader(Constants.HEAD); + assertTrue(reader.getLastEntry().getComment() + .startsWith("revert: Revert \"")); + reader = db.getReflogReader(db.getBranch()); + assertTrue(reader.getLastEntry().getComment() + .startsWith("revert: Revert \"")); + } } |