aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java
index 8084505c10..35de73e204 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java
@@ -46,6 +46,7 @@ import org.eclipse.jgit.lib.RefUpdate.Result;
import org.eclipse.jgit.lib.ReflogEntry;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
+import org.eclipse.jgit.lib.CommitConfig.CleanupMode;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.submodule.SubmoduleWalk;
@@ -515,6 +516,62 @@ public class CommitCommandTest extends RepositoryTestCase {
}
@Test
+ public void commitMessageVerbatim() throws Exception {
+ try (Git git = new Git(db)) {
+ writeTrashFile("file1", "file1");
+ git.add().addFilepattern("file1").call();
+ RevCommit committed = git.commit().setMessage("#initial commit")
+ .call();
+
+ assertEquals("#initial commit", committed.getFullMessage());
+ }
+ }
+
+ @Test
+ public void commitMessageStrip() throws Exception {
+ try (Git git = new Git(db)) {
+ writeTrashFile("file1", "file1");
+ git.add().addFilepattern("file1").call();
+ RevCommit committed = git.commit().setMessage(
+ "#Comment\ninitial commit\t\n\n commit body \n \t#another comment")
+ .setCleanupMode(CleanupMode.STRIP).call();
+
+ assertEquals("initial commit\n\n commit body",
+ committed.getFullMessage());
+ }
+ }
+
+ @Test
+ public void commitMessageDefault() throws Exception {
+ try (Git git = new Git(db)) {
+ writeTrashFile("file1", "file1");
+ git.add().addFilepattern("file1").call();
+ RevCommit committed = git.commit().setMessage(
+ "#Comment\ninitial commit\t\n\n commit body \n\n\n \t#another comment ")
+ .setCleanupMode(CleanupMode.DEFAULT).call();
+
+ assertEquals("initial commit\n\n commit body",
+ committed.getFullMessage());
+ }
+ }
+
+ @Test
+ public void commitMessageDefaultWhitespace() throws Exception {
+ try (Git git = new Git(db)) {
+ writeTrashFile("file1", "file1");
+ git.add().addFilepattern("file1").call();
+ RevCommit committed = git.commit().setMessage(
+ "#Comment\ninitial commit\t\n\n commit body \n\n\n \t#another comment ")
+ .setCleanupMode(CleanupMode.DEFAULT).setDefaultClean(false)
+ .call();
+
+ assertEquals(
+ "#Comment\ninitial commit\n\n commit body\n\n \t#another comment",
+ committed.getFullMessage());
+ }
+ }
+
+ @Test
public void commitEmptyCommits() throws Exception {
try (Git git = new Git(db)) {