Indicate trivial rebase and commit message update on push
Indication is appended to "Uploaded patch set N" message in the review history. For trivial rebase: Uploaded patch set 3: Patch set 2 was rebased. For commit message update: Uploaded patch set 3: Commit message was updated. Change-Id: Ic5e7c45feb2ea5f1b4607f5103153aa70ae6d7da
This commit is contained in:
@@ -76,6 +76,8 @@ import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.account.AccountCache;
|
||||
import com.google.gerrit.server.account.AccountResolver;
|
||||
import com.google.gerrit.server.change.ChangeInserter;
|
||||
import com.google.gerrit.server.change.ChangeKind;
|
||||
import com.google.gerrit.server.change.ChangeKindCache;
|
||||
import com.google.gerrit.server.change.ChangesCollection;
|
||||
import com.google.gerrit.server.change.MergeabilityChecker;
|
||||
import com.google.gerrit.server.change.RevisionResource;
|
||||
@@ -298,6 +300,7 @@ public class ReceiveCommits {
|
||||
private final SshInfo sshInfo;
|
||||
private final AllProjectsName allProjectsName;
|
||||
private final ReceiveConfig receiveConfig;
|
||||
private final ChangeKindCache changeKindCache;
|
||||
|
||||
private final ProjectControl projectControl;
|
||||
private final Project project;
|
||||
@@ -371,6 +374,7 @@ public class ReceiveCommits {
|
||||
final SubmoduleOp.Factory subOpFactory,
|
||||
final Provider<Submit> submitProvider,
|
||||
final MergeQueue mergeQueue,
|
||||
final ChangeKindCache changeKindCache,
|
||||
final DynamicMap<ProjectConfigEntry> pluginConfigEntries) throws IOException {
|
||||
this.currentUser = (IdentifiedUser) projectControl.getCurrentUser();
|
||||
this.db = db;
|
||||
@@ -404,6 +408,7 @@ public class ReceiveCommits {
|
||||
this.sshInfo = sshInfo;
|
||||
this.allProjectsName = allProjectsName;
|
||||
this.receiveConfig = config;
|
||||
this.changeKindCache = changeKindCache;
|
||||
|
||||
this.projectControl = projectControl;
|
||||
this.labelTypes = projectControl.getLabelTypes();
|
||||
@@ -1960,6 +1965,30 @@ public class ReceiveCommits {
|
||||
return Futures.makeChecked(future, INSERT_EXCEPTION);
|
||||
}
|
||||
|
||||
private ChangeMessage newChangeMessage(ReviewDb db) throws OrmException {
|
||||
msg =
|
||||
new ChangeMessage(new ChangeMessage.Key(change.getId(), ChangeUtil
|
||||
.messageUUID(db)), currentUser.getAccountId(), newPatchSet.getCreatedOn(),
|
||||
newPatchSet.getId());
|
||||
RevCommit priorCommit = revisions.inverse().get(priorPatchSet);
|
||||
ChangeKind changeKind = changeKindCache.getChangeKind(
|
||||
projectControl.getProjectState(), repo, priorCommit, newCommit);
|
||||
String message = "Uploaded patch set " + newPatchSet.getPatchSetId();
|
||||
switch (changeKind) {
|
||||
case TRIVIAL_REBASE:
|
||||
message += ": Patch Set " + priorPatchSet.get() + " was rebased";
|
||||
break;
|
||||
case NO_CODE_CHANGE:
|
||||
message += ": Commit message was updated";
|
||||
break;
|
||||
case REWORK:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
msg.setMessage(message + ".");
|
||||
return msg;
|
||||
}
|
||||
|
||||
PatchSet.Id insertPatchSet(ReviewDb db) throws OrmException, IOException {
|
||||
final Account.Id me = currentUser.getAccountId();
|
||||
final List<FooterLine> footerLines = newCommit.getFooterLines();
|
||||
@@ -1999,11 +2028,7 @@ public class ReceiveCommits {
|
||||
change, changeCtl, approvals);
|
||||
recipients.add(oldRecipients);
|
||||
|
||||
msg =
|
||||
new ChangeMessage(new ChangeMessage.Key(change.getId(), ChangeUtil
|
||||
.messageUUID(db)), me, newPatchSet.getCreatedOn(), newPatchSet.getId());
|
||||
msg.setMessage("Uploaded patch set " + newPatchSet.getPatchSetId() + ".");
|
||||
cmUtil.addChangeMessage(db, update, msg);
|
||||
cmUtil.addChangeMessage(db, update, newChangeMessage(db));
|
||||
|
||||
if (mergedIntoRef == null) {
|
||||
// Change should be new, so it can go through review again.
|
||||
|
Reference in New Issue
Block a user