diff options
author | Stefan Lay <stefan.lay@sap.com> | 2013-02-15 12:34:44 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2013-02-20 23:49:43 +0100 |
commit | 3b41fcbd96610dc0fddded2aebc4e3b5c702b4fb (patch) | |
tree | ba35aa7ee88f9872737decbb8796c47cf1fb4919 /org.eclipse.jgit.test/tst | |
parent | 9a5f4b46ccac22dd3dec8205ab50ec84f495db2f (diff) | |
download | jgit-3b41fcbd96610dc0fddded2aebc4e3b5c702b4fb.tar.gz jgit-3b41fcbd96610dc0fddded2aebc4e3b5c702b4fb.zip |
Accept Change-Id even if footer contains not well-formed entries
Instead of only looking for a Change-Id in the last section if it
consists only of well-formed "key: value" lines replace the last
occurrence of a valid Change-Id line in the last section. Some tools
require footer lines e.g. without a colon.
Gerrit doesn't accept Change-Id lines in the footer if the Change-Id
line doesn't start at the beginning of the line.
Bug: 400818
Change-Id: Icce54872adc8c566994beea848448a2f7ca87085
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/util/ChangeIdUtilTest.java | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/ChangeIdUtilTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/ChangeIdUtilTest.java index 54f3114c6d..66649b1006 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/ChangeIdUtilTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/ChangeIdUtilTest.java @@ -642,29 +642,58 @@ public class ChangeIdUtilTest { assertEquals(3, ChangeIdUtil.indexOfChangeId("x\n" + "\n" + "Change-Id: I3b7e4e16b503ce00f07ba6ad01d97a356dad7701\n", "\n")); + assertEquals(3, ChangeIdUtil.indexOfChangeId("x\n" + "\n" + + "Change-Id: I3b7e4e16b503ce00f07ba6ad01d97a356dad7701\n\n\n", + "\n")); + assertEquals(3, ChangeIdUtil.indexOfChangeId("x\n" + "\n" + + "Change-Id: I3b7e4e16b503ce00f07ba6ad01d97a356dad7701\n \n \n", + "\n")); + assertEquals(3, ChangeIdUtil.indexOfChangeId("x\n" + "\n" + + "Change-Id: I3b7e4e16b503ce00f07ba6ad01d97a356dad7701\n", + "\n")); + + // leading whitespace is rejected by Gerrit + assertEquals(-1, ChangeIdUtil.indexOfChangeId("x\n" + "\n" + + " Change-Id: I3b7e4e16b503ce00f07ba6ad01d97a356dad7701\n", + "\n")); + assertEquals(-1, ChangeIdUtil.indexOfChangeId("x\n" + "\n" + + "\t Change-Id: I3b7e4e16b503ce00f07ba6ad01d97a356dad7701\n", + "\n")); + + assertEquals(-1, ChangeIdUtil.indexOfChangeId("x\n" + "\n" + + "Change-Id: \n", "\n")); + assertEquals(3, ChangeIdUtil.indexOfChangeId("x\n" + "\n" + + "Change-Id: I3b7e4e16b503ce00f07ba6ad01d97a356dad7701 \n", + "\n")); + assertEquals(12, ChangeIdUtil.indexOfChangeId("x\n" + "\n" + + "Bug 4711\n" + + "Change-Id: I3b7e4e16b503ce00f07ba6ad01d97a356dad7701\n", + "\n")); + assertEquals(56, ChangeIdUtil.indexOfChangeId("x\n" + + "Change-Id: I3b7e4e16b503ce00f07ba6ad01d97a356dad7701\n" + + "\n" + + "Change-Id: I3b7e4e16b503ce00f07ba6ad01d97a356dad7701\n", + "\n")); + assertEquals(-1, ChangeIdUtil.indexOfChangeId("x\n" + + "Change-Id: I3b7e4e16b503ce00f07ba6ad01d97a356dad7701\n" + + "\n" + "x\n", "\n")); + assertEquals(-1, ChangeIdUtil.indexOfChangeId("x\n\n" + + "Change-Id: I3b7e4e16b503ce00f07ba6ad01d97a356dad7701\n" + + "\n" + "x\n", "\n")); assertEquals(5, ChangeIdUtil.indexOfChangeId("x\r\n" + "\r\n" + "Change-Id: I3b7e4e16b503ce00f07ba6ad01d97a356dad7701\r\n", "\r\n")); assertEquals(3, ChangeIdUtil.indexOfChangeId("x\r" + "\r" + "Change-Id: I3b7e4e16b503ce00f07ba6ad01d97a356dad7701\r", "\r")); + assertEquals(3, ChangeIdUtil.indexOfChangeId("x\r" + "\r" + + "Change-Id: I3b7e4e16b503ce00f07ba6ad01d97a356dad7701\r", + "\r")); assertEquals(8, ChangeIdUtil.indexOfChangeId("x\ny\n\nz\n" + "\n" + "Change-Id: I3b7e4e16b503ce00f07ba6ad01d97a356dad7701\n", "\n")); } - @Test - public void testIndexOfFirstFooterLine() { - assertEquals( - 2, - ChangeIdUtil.indexOfFirstFooterLine(new String[] { "a", "", - "Bug: 42", "Signed-Off-By: j.developer@a.com" })); - assertEquals( - 3, - ChangeIdUtil.indexOfFirstFooterLine(new String[] { "a", - "Bug: 42", "", "Signed-Off-By: j.developer@a.com" })); - } - private void hookDoesNotModify(final String in) throws Exception { assertEquals(in, call(in)); } |