]> source.dussan.org Git - jgit.git/commitdiff
TestRepository: Ignore existing Change-Id in message 48/43748/1
authorDave Borowitz <dborowitz@google.com>
Thu, 12 Mar 2015 19:01:44 +0000 (12:01 -0700)
committerDave Borowitz <dborowitz@google.com>
Thu, 12 Mar 2015 19:46:50 +0000 (12:46 -0700)
Change-Id: I343c3065fa369ef8aab2b033ac1e392b28d10daf

org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/junit/TestRepositoryTest.java

index 371e139a889ad733d9fc7df279a8ec3817ecba1a..2afc7163b0493bf082766bb5a2f97aef0150818d 100644 (file)
@@ -1045,6 +1045,10 @@ public class TestRepository<R extends Repository> {
 
                private void insertChangeId(org.eclipse.jgit.lib.CommitBuilder c)
                                throws IOException {
+                       int idx = ChangeIdUtil.indexOfChangeId(message, "\n");
+                       if (idx >= 0)
+                               return;
+
                        ObjectId firstParentId = null;
                        if (!parents.isEmpty())
                                firstParentId = parents.get(0);
index 87ce0117637f11eda8cd5d2e39935a097af7dc52..09259de7db74b479b8df6b96fbafd94936e377e2 100644 (file)
@@ -102,6 +102,16 @@ public class TestRepositoryTest {
                                c2.getFullMessage());
        }
 
+       @Test
+       public void insertChangeIdIgnoresExisting() throws Exception {
+               String msg = "message\n"
+                               + "\n"
+                               +       "Change-Id: Ideadbeefdeadbeefdeadbeefdeadbeefdeadbeef\n";
+               RevCommit c = tr.commit().message(msg).insertChangeId().create();
+               rw.parseBody(c);
+               assertEquals(msg, c.getFullMessage());
+       }
+
        @Test
        public void resetFromSymref() throws Exception {
                repo.updateRef("HEAD").link("refs/heads/master");