summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2013-08-10 18:31:01 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2013-08-10 18:31:01 -0400
commitc58405b0c305d9bc91b22858b8f2ede667596a57 (patch)
tree4f7d3f14e50bc0c2341d28a3f12a77f35ac903a1 /org.eclipse.jgit.test/tst
parentb6e5189c4ece48e65633c3a3ee79981004acfa6e (diff)
parentb0ffacf1226e3c0b0d8fd6ed0beb7311e508dc14 (diff)
downloadjgit-c58405b0c305d9bc91b22858b8f2ede667596a57.tar.gz
jgit-c58405b0c305d9bc91b22858b8f2ede667596a57.zip
Merge "Recognize CRLF when parsing the short message of a commit or tag"
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java13
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/StringUtilsTest.java12
2 files changed, 25 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java
index 574f85c91a..beda2a7b97 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java
@@ -383,6 +383,19 @@ public class RevCommitParseTest extends RepositoryTestCase {
assertEquals(src.getMessage(), p.getFullMessage());
}
+ @Test
+ public void testParse_GitStyleMessageWithCRLF() throws Exception {
+ final String shortMsgIn = "This fixes a\r\nbug.\r\n\r\n";
+ final String shortMsg = "This fixes a bug.";
+ final String body = "We do it with magic and pixie dust\r\nand stuff.\r\n"
+ + "\r\n\r\n"
+ + "Signed-off-by: A U. Thor <author@example.com>\r\n";
+ final String fullMsg = shortMsgIn + "\r\n" + "\r\n" + body;
+ final RevCommit c = create(fullMsg);
+ assertEquals(fullMsg, c.getFullMessage());
+ assertEquals(shortMsg, c.getShortMessage());
+ }
+
private static ObjectId id(final String str) {
return ObjectId.fromString(str);
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/StringUtilsTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/StringUtilsTest.java
index d7b92ade9d..86fed22afe 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/StringUtilsTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/StringUtilsTest.java
@@ -91,4 +91,16 @@ public class StringUtilsTest {
assertTrue(StringUtils.equalsIgnoreCase("A", "a"));
assertTrue(StringUtils.equalsIgnoreCase("a", "A"));
}
+
+ @Test
+ public void testReplaceLineBreaks() {
+ assertEquals("a b c ",
+ StringUtils.replaceLineBreaksWithSpace("a b\nc\r"));
+ assertEquals("a b c ",
+ StringUtils.replaceLineBreaksWithSpace("a b\nc\n"));
+ assertEquals("a b c ",
+ StringUtils.replaceLineBreaksWithSpace("a b\nc\r\n"));
+ assertEquals("a b c d",
+ StringUtils.replaceLineBreaksWithSpace("a\r\nb\nc d"));
+ }
}