Refactor composeGitlinksCommit in SubmoduleOp

* Separate the cases for create a new commit and amend an existing
commit, since some logics are totally different in these two cases.
* Fix a few glitches when gitlink is already updated.
* Prettify commit message.

Change-Id: If1c66fb5d183abe0e4729cf4183323ab354123d6
This commit is contained in:
Zhen Chen
2016-07-20 18:02:19 -07:00
parent fffb2216c8
commit d8f32f39d3
2 changed files with 148 additions and 105 deletions

View File

@@ -215,21 +215,18 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
// The first update doesn't include the rev log
RevWalk rw = subRepo.getRevWalk();
RevCommit subCommitMsg = rw.parseCommit(subHEAD);
expectToHaveCommitMessage(superRepo, "master",
"Update git submodules\n\n" +
"Project: " + name("subscribed-to-project")
+ " master " + subHEAD.name() + "\n\n");
"* Update " + name("subscribed-to-project") + " from branch 'master'");
// The next commit should generate only its commit message,
// omitting previous commit logs
subHEAD = pushChangeTo(subRepo, "master");
subCommitMsg = rw.parseCommit(subHEAD);
RevCommit subCommitMsg = rw.parseCommit(subHEAD);
expectToHaveCommitMessage(superRepo, "master",
"Update git submodules\n\n" +
"Project: " + name("subscribed-to-project")
+ " master " + subHEAD.name() + "\n\n" +
subCommitMsg.getFullMessage() + "\n\n");
"* Update " + name("subscribed-to-project") + " from branch 'master'"
+ "\n - " + subCommitMsg.getFullMessage().replace("\n", "\n "));
}
@Test