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.AccountCache;
|
||||||
import com.google.gerrit.server.account.AccountResolver;
|
import com.google.gerrit.server.account.AccountResolver;
|
||||||
import com.google.gerrit.server.change.ChangeInserter;
|
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.ChangesCollection;
|
||||||
import com.google.gerrit.server.change.MergeabilityChecker;
|
import com.google.gerrit.server.change.MergeabilityChecker;
|
||||||
import com.google.gerrit.server.change.RevisionResource;
|
import com.google.gerrit.server.change.RevisionResource;
|
||||||
@@ -298,6 +300,7 @@ public class ReceiveCommits {
|
|||||||
private final SshInfo sshInfo;
|
private final SshInfo sshInfo;
|
||||||
private final AllProjectsName allProjectsName;
|
private final AllProjectsName allProjectsName;
|
||||||
private final ReceiveConfig receiveConfig;
|
private final ReceiveConfig receiveConfig;
|
||||||
|
private final ChangeKindCache changeKindCache;
|
||||||
|
|
||||||
private final ProjectControl projectControl;
|
private final ProjectControl projectControl;
|
||||||
private final Project project;
|
private final Project project;
|
||||||
@@ -371,6 +374,7 @@ public class ReceiveCommits {
|
|||||||
final SubmoduleOp.Factory subOpFactory,
|
final SubmoduleOp.Factory subOpFactory,
|
||||||
final Provider<Submit> submitProvider,
|
final Provider<Submit> submitProvider,
|
||||||
final MergeQueue mergeQueue,
|
final MergeQueue mergeQueue,
|
||||||
|
final ChangeKindCache changeKindCache,
|
||||||
final DynamicMap<ProjectConfigEntry> pluginConfigEntries) throws IOException {
|
final DynamicMap<ProjectConfigEntry> pluginConfigEntries) throws IOException {
|
||||||
this.currentUser = (IdentifiedUser) projectControl.getCurrentUser();
|
this.currentUser = (IdentifiedUser) projectControl.getCurrentUser();
|
||||||
this.db = db;
|
this.db = db;
|
||||||
@@ -404,6 +408,7 @@ public class ReceiveCommits {
|
|||||||
this.sshInfo = sshInfo;
|
this.sshInfo = sshInfo;
|
||||||
this.allProjectsName = allProjectsName;
|
this.allProjectsName = allProjectsName;
|
||||||
this.receiveConfig = config;
|
this.receiveConfig = config;
|
||||||
|
this.changeKindCache = changeKindCache;
|
||||||
|
|
||||||
this.projectControl = projectControl;
|
this.projectControl = projectControl;
|
||||||
this.labelTypes = projectControl.getLabelTypes();
|
this.labelTypes = projectControl.getLabelTypes();
|
||||||
@@ -1960,6 +1965,30 @@ public class ReceiveCommits {
|
|||||||
return Futures.makeChecked(future, INSERT_EXCEPTION);
|
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 {
|
PatchSet.Id insertPatchSet(ReviewDb db) throws OrmException, IOException {
|
||||||
final Account.Id me = currentUser.getAccountId();
|
final Account.Id me = currentUser.getAccountId();
|
||||||
final List<FooterLine> footerLines = newCommit.getFooterLines();
|
final List<FooterLine> footerLines = newCommit.getFooterLines();
|
||||||
@@ -1999,11 +2028,7 @@ public class ReceiveCommits {
|
|||||||
change, changeCtl, approvals);
|
change, changeCtl, approvals);
|
||||||
recipients.add(oldRecipients);
|
recipients.add(oldRecipients);
|
||||||
|
|
||||||
msg =
|
cmUtil.addChangeMessage(db, update, newChangeMessage(db));
|
||||||
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);
|
|
||||||
|
|
||||||
if (mergedIntoRef == null) {
|
if (mergedIntoRef == null) {
|
||||||
// Change should be new, so it can go through review again.
|
// Change should be new, so it can go through review again.
|
||||||
|
|||||||
Reference in New Issue
Block a user