|
|
|
@ -68,6 +68,7 @@ import org.eclipse.jgit.lib.Repository;
|
|
|
|
|
import org.eclipse.jgit.lib.RepositoryTestCase; |
|
|
|
|
import org.eclipse.jgit.revwalk.RevCommit; |
|
|
|
|
import org.eclipse.jgit.revwalk.RevWalk; |
|
|
|
|
import org.eclipse.jgit.storage.file.ReflogReader; |
|
|
|
|
import org.eclipse.jgit.treewalk.TreeWalk; |
|
|
|
|
import org.eclipse.jgit.util.FileUtils; |
|
|
|
|
import org.junit.Test; |
|
|
|
@ -150,8 +151,8 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testSomeCommits() throws NoHeadException, NoMessageException, |
|
|
|
|
UnmergedPathException, ConcurrentRefUpdateException, |
|
|
|
|
JGitInternalException, WrongRepositoryStateException { |
|
|
|
|
ConcurrentRefUpdateException, JGitInternalException, |
|
|
|
|
WrongRepositoryStateException, IOException { |
|
|
|
|
|
|
|
|
|
// do 4 commits
|
|
|
|
|
Git git = new Git(db); |
|
|
|
@ -180,6 +181,8 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
|
|
|
|
|
l--; |
|
|
|
|
} |
|
|
|
|
assertEquals(l, -1); |
|
|
|
|
ReflogReader reader = db.getReflogReader(Constants.HEAD); |
|
|
|
|
assertTrue(reader.getLastEntry().getComment().startsWith("commit:")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// try to do a commit without specifying a message. Should fail!
|
|
|
|
@ -319,8 +322,8 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testCommitAmend() throws NoHeadException, NoMessageException, |
|
|
|
|
UnmergedPathException, ConcurrentRefUpdateException, |
|
|
|
|
JGitInternalException, WrongRepositoryStateException { |
|
|
|
|
ConcurrentRefUpdateException, JGitInternalException, |
|
|
|
|
WrongRepositoryStateException, IOException { |
|
|
|
|
Git git = new Git(db); |
|
|
|
|
git.commit().setMessage("first comit").call(); // typo
|
|
|
|
|
git.commit().setAmend(true).setMessage("first commit").call(); |
|
|
|
@ -332,6 +335,9 @@ public class CommitAndLogCommandTests extends RepositoryTestCase {
|
|
|
|
|
c++; |
|
|
|
|
} |
|
|
|
|
assertEquals(1, c); |
|
|
|
|
ReflogReader reader = db.getReflogReader(Constants.HEAD); |
|
|
|
|
assertTrue(reader.getLastEntry().getComment() |
|
|
|
|
.startsWith("commit (amend):")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|