Correct review message when a change is rebased
When a change is rebased from the Web UI, a comment is added: Patch Set 1: Patch Set 1 was rebased But the message should refer to the patch set that was created by the rebase, i.e.: Patch Set 2: Patch Set 1 was rebased The wrong patch set number is used because the message is constructed using `currentPatchSetId`, but this does not work as expected because it is called before the new patch set is inserted and returns the ID of the current patch set before the rebase. Add a new method on the PatchSetInserter to get the ID of the patch set that will be added. Use this to construct the review message. Change-Id: I589acf072768e78d1520d8692e011df5f211069c
This commit is contained in:
@@ -151,6 +151,11 @@ public class PatchSetInserter {
|
||||
return this;
|
||||
}
|
||||
|
||||
public PatchSet.Id getPatchSetId() {
|
||||
init();
|
||||
return patchSet.getId();
|
||||
}
|
||||
|
||||
public PatchSetInserter setMessage(String message) throws OrmException {
|
||||
changeMessage = new ChangeMessage(new ChangeMessage.Key(change.getId(),
|
||||
ChangeUtil.messageUUID(db)), user.getAccountId(), patchSet.getId());
|
||||
|
||||
@@ -293,7 +293,7 @@ public class RebaseChange {
|
||||
final ChangeControl changeControl =
|
||||
changeControlFactory.validateFor(change.getId(), uploader);
|
||||
|
||||
PatchSetInserter patchSetinserter = patchSetInserterFactory
|
||||
PatchSetInserter patchSetInserter = patchSetInserterFactory
|
||||
.create(git, revWalk, changeControl.getRefControl(), uploader, change, rebasedCommit)
|
||||
.setCopyLabels(true)
|
||||
.setValidatePolicy(validate)
|
||||
@@ -301,13 +301,15 @@ public class RebaseChange {
|
||||
.setSendMail(sendMail)
|
||||
.setRunHooks(runHooks);
|
||||
|
||||
final PatchSet.Id newPatchSetId = patchSetInserter.getPatchSetId();
|
||||
final ChangeMessage cmsg =
|
||||
new ChangeMessage(new ChangeMessage.Key(change.getId(),
|
||||
ChangeUtil.messageUUID(db)), uploader.getAccountId(), patchSetId);
|
||||
cmsg.setMessage("Patch Set " + change.currentPatchSetId().get()
|
||||
|
||||
cmsg.setMessage("Patch Set " + newPatchSetId.get()
|
||||
+ ": Patch Set " + patchSetId.get() + " was rebased");
|
||||
|
||||
Change newChange = patchSetinserter
|
||||
Change newChange = patchSetInserter
|
||||
.setMessage(cmsg)
|
||||
.insert();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user