aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorStefan Lay <stefan.lay@sap.com>2010-08-05 14:11:38 +0200
committerChris Aniszczyk <caniszczyk@gmail.com>2010-08-05 12:23:38 -0500
commit4b464ed458199476ec6547ff7fcdd9dd6f6608e6 (patch)
treed61f4c4169743a930fc65a68775bcad1ce804471 /org.eclipse.jgit.test
parent60c5939b236723cb43344115eed03caf8de2b22a (diff)
downloadjgit-4b464ed458199476ec6547ff7fcdd9dd6f6608e6.tar.gz
jgit-4b464ed458199476ec6547ff7fcdd9dd6f6608e6.zip
Allow to replace existing Change-Id
It is useful to be able to replace an existing Change-Id in the message, for example if the user decides not to amend the previous commit. Bug: 321188 Change-Id: I594e7f9efd0c57d794d2bd26d55ec45f4e6a47fd Signed-off-by: Stefan Lay <stefan.lay@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/ChangeIdUtilTest.java54
1 files changed, 53 insertions, 1 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 3b1584612d..a15cadfbda 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
@@ -123,6 +123,13 @@ public class ChangeIdUtilTest extends TestCase {
call("has changeid\n\nBug: 33\nmore text\nSigned-off-by: me@you.too\nChange-Id: I0123456789012345678901234567890123456789\nAnd then some\n"));
}
+ public void testHasChangeidWithReplacement() throws Exception {
+ assertEquals(
+ "has changeid\n\nBug: 33\nmore text\nSigned-off-by: me@you.too\nChange-Id: I988d2d7a6f2c0578fccabd4ebd3cec0768bc7f9f\nAnd then some\n",
+ call("has changeid\n\nBug: 33\nmore text\nSigned-off-by: me@you.too\nChange-Id: I0123456789012345678901234567890123456789\nAnd then some\n",
+ true));
+ }
+
public void testOneliner() throws Exception {
assertEquals(
"oneliner\n\nChange-Id: I3a98091ce4470de88d52ae317fcd297e2339f063\n",
@@ -236,6 +243,47 @@ public class ChangeIdUtilTest extends TestCase {
"Change-Id: I4f4e2e1e8568ddc1509baecb8c1270a1fb4b6da7\n");
}
+ public void testChangeIdAlreadySetWithReplacement() throws Exception {
+ // If a Change-Id is already present in the footer, the hook
+ // replaces the Change-Id with the new value..
+ //
+ assertEquals("a\n" + //
+ "\n" + //
+ "Change-Id: Ifa324efa85bfb3c8696a46a0f67fa70c35be5f5f\n",
+ call("a\n" + //
+ "\n" + //
+ "Change-Id: Iaeac9b4149291060228ef0154db2985a31111335\n",
+ true));
+ assertEquals("fix: this thing\n" + //
+ "\n" + //
+ "Change-Id: Ib63e4990a06412a3f24bd93bb160e98ac1bd412b\n",
+ call("fix: this thing\n" + //
+ "\n" + //
+ "Change-Id: I388bdaf52ed05b55e62a22d0a20d2c1ae0d33e7e\n",
+ true));
+ assertEquals("fix-a-widget: this thing\n" + //
+ "\n" + //
+ "Change-Id: If0444e4d0cabcf41b3d3b46b7e9a7a64a82117af\n",
+ call("fix-a-widget: this thing\n" + //
+ "\n" + //
+ "Change-Id: Id3bc5359d768a6400450283e12bdfb6cd135ea4b\n",
+ true));
+ assertEquals("FIX: this thing\n" + //
+ "\n" + //
+ "Change-Id: Iba5a3b2d5e5df46448f6daf362b6bfa775c6491d\n",
+ call("FIX: this thing\n" + //
+ "\n" + //
+ "Change-Id: I1b55098b5a2cce0b3f3da783dda50d5f79f873fa\n",
+ true));
+ assertEquals("Fix-A-Widget: this thing\n" + //
+ "\n" + //
+ "Change-Id: I2573d47c62c42429fbe424d70cfba931f8f87848\n",
+ call("Fix-A-Widget: this thing\n" + //
+ "\n" + //
+ "Change-Id: I4f4e2e1e8568ddc1509baecb8c1270a1fb4b6da7\n",
+ true));
+ }
+
public void testTimeAltersId() throws Exception {
assertEquals("a\n" + //
"\n" + //
@@ -513,11 +561,15 @@ public class ChangeIdUtilTest extends TestCase {
}
private String call(final String body) throws Exception {
+ return call(body, false);
+ }
+
+ private String call(final String body, boolean replaceExisting) throws Exception {
ObjectId computeChangeId = ChangeIdUtil.computeChangeId(treeId1,
parentId1, author, committer, body);
if (computeChangeId == null)
return body;
- return ChangeIdUtil.insertId(body, computeChangeId);
+ return ChangeIdUtil.insertId(body, computeChangeId, replaceExisting);
}
}