Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2015-10-20 21:27:02 +0000
committerMatthias Sohn2015-10-26 07:55:52 +0000
commitaed7ab481264851014f5bcba1d45d9e9d03c4392 (patch)
tree9471b8e9c57c5596b8a044f61be682a8caaede0e /org.eclipse.egit.ui.test
parent2f9171f9268056c6a99aa24dc693fc8dd5bc5b56 (diff)
downloadegit-aed7ab481264851014f5bcba1d45d9e9d03c4392.tar.gz
egit-aed7ab481264851014f5bcba1d45d9e9d03c4392.tar.xz
egit-aed7ab481264851014f5bcba1d45d9e9d03c4392.zip
Do not wrap commit message footer lines
Wrapping commit message footer lines may break the expected format of those lines. Bug: 478659 Change-Id: I0169c4cc278318a702bbed2c6e5d7ff99038406f Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui.test')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/CommonUtilsTest.java29
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/dialogs/SpellcheckableMessageAreaTest.java30
2 files changed, 59 insertions, 0 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/CommonUtilsTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/CommonUtilsTest.java
index 5ab6c18250..e7805cf720 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/CommonUtilsTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/CommonUtilsTest.java
@@ -1,6 +1,7 @@
/*******************************************************************************
* Copyright (C) 2011, Robin Stocker <robin@nibor.org>
* Copyright (C) 2013, Michael Keppler <michael.keppler@gmx.de>
+ * Copyright (C) 2015, Thomas Wolf <thomas.wolf@paranor.ch>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -140,4 +141,32 @@ public class CommonUtilsTest {
p.getProject().getFolder("test").delete(false, monitor);
p.getProject().delete(false, monitor);
}
+
+ @Test
+ public void testFooterOffsetNoFooter() {
+ assertEquals(-1, CommonUtils.getFooterOffset(""));
+ assertEquals(-1, CommonUtils.getFooterOffset("line 1"));
+ assertEquals(-1, CommonUtils.getFooterOffset("line 1\nFoobar"));
+ assertEquals(-1, CommonUtils.getFooterOffset("line 1\n\nFoobar"));
+ assertEquals(-1, CommonUtils.getFooterOffset("line 1\nFoo:bar"));
+ assertEquals(-1, CommonUtils.getFooterOffset("line 1\n_\nFoo:bar"));
+ }
+
+ @Test
+ public void testFooterOffset() {
+ assertEquals(8, CommonUtils.getFooterOffset("line 1\n\nFoo:bar"));
+ assertEquals(8, CommonUtils.getFooterOffset("line 1\n\nFoo:bar "));
+ assertEquals(8, CommonUtils.getFooterOffset("line 1\n\nFoo:bar\n "));
+ assertEquals(8, CommonUtils.getFooterOffset("line 1\n\nFoo:bar\n \n"));
+ assertEquals(8, CommonUtils
+ .getFooterOffset("line 1\n\nFoo:bar\nFoobar: barbar"));
+ assertEquals(8, CommonUtils
+ .getFooterOffset("line 1\n\nFoo:bar\nFoobar: barbar "));
+ assertEquals(8, CommonUtils
+ .getFooterOffset("line 1\n\nFoo:bar\nFoobar: barbar\n "));
+ assertEquals(10,
+ CommonUtils.getFooterOffset("line 1\n \nFoo:bar\n \n"));
+ assertEquals(17, CommonUtils
+ .getFooterOffset("line 1\n\nFoo:bar\n\nFoobar: barbar\n "));
+ }
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/dialogs/SpellcheckableMessageAreaTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/dialogs/SpellcheckableMessageAreaTest.java
index f52091994d..d9d2dd3e36 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/dialogs/SpellcheckableMessageAreaTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/dialogs/SpellcheckableMessageAreaTest.java
@@ -2,6 +2,7 @@
* Copyright (C) 2010, Robin Stocker
* Copyright (C) 2011, Matthias Sohn <matthias.sohn@sap.com>
* Copyright (C) 2012, IBM Corporation (Markus Keller <markus_keller@ch.ibm.com>)
+ * Copyright (C) 2015, Thomas Wolf <thomas.wolf@paranor.ch>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -188,4 +189,33 @@ public class SpellcheckableMessageAreaTest {
String wrapped = SpellcheckableMessageArea.hardWrap(Utils.normalizeLineEndings(text));
return wrapped.replaceAll("\n", lineDelimiter);
}
+
+ @Test
+ public void dontWrapShortMessage() {
+ String input = "short";
+ assertEquals(input, SpellcheckableMessageArea.wrapCommitMessage(input));
+ }
+
+ @Test
+ public void dontWrapLongCommitMessageFooter() {
+ String input = "short\n\nfoo\n\n"
+ + "Change-Id: I0000000000000000000000000000000000000000\n"
+ + "Signed-off-by: Some-Arguablylong Name <jsomearguablylong.name@somecompany.com>";
+ assertEquals(input, SpellcheckableMessageArea.wrapCommitMessage(input));
+ }
+
+ @Test
+ public void wrapOnlyCommitMessageBody() {
+ String input = "short\n\n"
+ + "123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789\n\n"
+ + "Change-Id: I0000000000000000000000000000000000000000\n"
+ + "Signed-off-by: Some-Arguablylong Name <somearguablylong.name@somecompany.com>";
+ String expected = "short\n\n"
+ + "123456789 123456789 123456789 123456789 123456789 123456789 123456789\n"
+ + "123456789\n\n"
+ + "Change-Id: I0000000000000000000000000000000000000000\n"
+ + "Signed-off-by: Some-Arguablylong Name <somearguablylong.name@somecompany.com>";
+ assertEquals(expected,
+ SpellcheckableMessageArea.wrapCommitMessage(input));
+ }
}

Back to the top