ReceiveCommits: Prevent NPE setting updated change list for edit commit

When pushing an amended commit with the %edit option, the ReplaceRequest
has null info, which causes NPE when trying to use it to get the subject
of the new patch set. This results in the message:

  "internal error while processing changes"

to be shown to the user instead of the "Updated Changes" list.

Use the ReplaceRequest's newCommit instead.

Also update AbstractPushForReview#testPushForMasterAsEdit to confirm that
the expected "Updated Changes" output is present.

Bug: Issue 4236
Change-Id: I82983219a3220d21f043fdc662f561e291fc0746
This commit is contained in:
David Pursehouse 2016-07-06 11:29:18 +09:00
parent 9775399ea2
commit a0157917f2
2 changed files with 5 additions and 1 deletions

View File

@ -176,6 +176,10 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
r.assertOkStatus();
edit = getEdit(r.getChangeId());
assertThat(edit).isNotNull();
r.assertMessage("Updated Changes:\n "
+ canonicalWebUrl.get()
+ r.getChange().getId()
+ " " + edit.commit.subject + " [EDIT]\n");
}
@Test

View File

@ -722,7 +722,7 @@ public class ReceiveCommits {
boolean edit = magicBranch != null && magicBranch.edit;
for (ReplaceRequest u : updated) {
addMessage(formatChangeUrl(canonicalWebUrl, u.change,
u.info.getSubject(), edit));
u.newCommit.getShortMessage(), edit));
}
addMessage("");
}