Specify new tip of the branch when updating submodules

In Gerrit 2.12 whenever a submodule was updated the corresponding commit
in the superproject included the SHA-1 of the new tip of the branch.

Restore this behavior to avoid breaking clients that extract this
information from the superproject commit message.

After this change, the commit message in the superproject looks like:

  Update git submodules

  * Update submodule_project from branch 'master'
    to ec435bcab13e373643f2bf833d41954898774fcd
    - Add file 17

      More lines of commit message here...

      Change-Id: I67b568ccb7ee077fec81541a4eeae13814252e07

    - Add file 16

      Here the commit message goes explaining...

      Change-Id: I45a24ea2f4416ebf2b81a58a51a43d7a56a774ef

Change-Id: I4fa483d7124fb875f29ee1ec7bcf0f776322640c
This commit is contained in:
Hector Oswaldo Caballero
2017-10-31 13:19:13 -04:00
parent 61f90b9654
commit 725bf7f460
2 changed files with 5 additions and 4 deletions

View File

@@ -243,7 +243,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
"Update git submodules\n\n"
+ "* Update "
+ name("subscribed-to-project")
+ " from branch 'master'");
+ " from branch 'master'\n to " + subHEAD.getName());
// The next commit should generate only its commit message,
// omitting previous commit logs
@@ -255,7 +255,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
"Update git submodules\n\n"
+ "* Update "
+ name("subscribed-to-project")
+ " from branch 'master'"
+ " from branch 'master'\n to " + subHEAD.getName()
+ "\n - "
+ subCommitMsg.getShortMessage());
}
@@ -279,7 +279,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
"Update git submodules\n\n"
+ "* Update "
+ name("subscribed-to-project")
+ " from branch 'master'");
+ " from branch 'master'\n to " + subHEAD.getName());
// The next commit should generate only its commit message,
// omitting previous commit logs
@@ -291,7 +291,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
"Update git submodules\n\n"
+ "* Update "
+ name("subscribed-to-project")
+ " from branch 'master'"
+ " from branch 'master'\n to " + subHEAD.getName()
+ "\n - "
+ subCommitMsg.getFullMessage().replace("\n", "\n "));
}

View File

@@ -516,6 +516,7 @@ public class SubmoduleOp {
throws SubmoduleException {
msgbuf.append("* Update " + s.getPath());
msgbuf.append(" from branch '" + s.getSubmodule().getShortName() + "'");
msgbuf.append("\n to " + newCommit.getName());
// newly created submodule gitlink, do not append whole history
if (oldCommit == null) {