Merge "Prevent new patchset notification emails for trivial rebase"

This commit is contained in:
David Pursehouse 2015-02-13 08:14:36 +00:00 committed by Gerrit Code Review
commit a34ecbed8e
4 changed files with 39 additions and 34 deletions

View File

@ -228,6 +228,7 @@ public class CherryPickChange {
.setMessage("Uploaded patch set " + newPatchSetId.get() + ".")
.setDraft(current.isDraft())
.setUploader(identifiedUser.getAccountId())
.setSendMail(false)
.insert();
return change.getId();
}

View File

@ -138,7 +138,7 @@ public class RebaseChange {
rebase(git, rw, inserter, patchSetId, change,
uploader, baseCommit, mergeUtilFactory.create(
changeControl.getProjectControl().getProjectState(), true),
committerIdent, true, true, ValidatePolicy.GERRIT);
committerIdent, true, ValidatePolicy.GERRIT);
} catch (MergeConflictException e) {
throw new IOException(e.getMessage());
} finally {
@ -265,7 +265,6 @@ public class RebaseChange {
* @param baseCommit the commit that should be the new base
* @param mergeUtil merge utilities for the destination project
* @param committerIdent the committer's identity
* @param sendMail if a mail notification should be sent for the new patch set
* @param runHooks if hooks should be run for the new patch set
* @param validate if commit validation should be run for the new patch set
* @return the new patch set which is based on the given base commit
@ -279,7 +278,7 @@ public class RebaseChange {
final ObjectInserter inserter, final PatchSet.Id patchSetId,
final Change change, final IdentifiedUser uploader, final RevCommit baseCommit,
final MergeUtil mergeUtil, PersonIdent committerIdent,
boolean sendMail, boolean runHooks, ValidatePolicy validate)
boolean runHooks, ValidatePolicy validate)
throws NoSuchChangeException,
OrmException, IOException, InvalidChangeOperationException,
MergeConflictException {
@ -303,7 +302,7 @@ public class RebaseChange {
.setValidatePolicy(validate)
.setDraft(originalPatchSet.isDraft())
.setUploader(uploader.getAccountId())
.setSendMail(sendMail)
.setSendMail(false)
.setRunHooks(runHooks);
final PatchSet.Id newPatchSetId = patchSetInserter.getPatchSetId();

View File

@ -1985,14 +1985,12 @@ public class ReceiveCommits {
return Futures.makeChecked(future, INSERT_EXCEPTION);
}
private ChangeMessage newChangeMessage(ReviewDb db) throws OrmException {
private ChangeMessage newChangeMessage(ReviewDb db, ChangeKind changeKind)
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:
@ -2032,6 +2030,7 @@ public class ReceiveCommits {
recipients.remove(me);
db.changes().beginTransaction(change.getId());
ChangeKind changeKind = ChangeKind.REWORK;
try {
change = db.changes().get(change.getId());
if (change == null || change.getStatus().isClosed()) {
@ -2057,7 +2056,11 @@ public class ReceiveCommits {
changeCtl, approvals);
recipients.add(oldRecipients);
cmUtil.addChangeMessage(db, update, newChangeMessage(db));
RevCommit priorCommit = revisions.inverse().get(priorPatchSet);
changeKind = changeKindCache.getChangeKind(
projectControl.getProjectState(), repo, priorCommit, newCommit);
cmUtil.addChangeMessage(db, update, newChangeMessage(db, changeKind));
if (mergedIntoRef == null) {
// Change should be new, so it can go through review again.
@ -2119,6 +2122,7 @@ public class ReceiveCommits {
cmd.execute(rp);
}
CheckedFuture<?, IOException> f = indexer.indexAsync(change.getId());
if (changeKind != ChangeKind.TRIVIAL_REBASE) {
workQueue.getDefaultQueue()
.submit(requestScopePropagator.wrap(new Runnable() {
@Override
@ -2145,6 +2149,7 @@ public class ReceiveCommits {
return "send-email newpatchset";
}
}));
}
f.checkedGet();
gitRefUpdated.fire(project.getNameKey(), newPatchSet.getRefName(),

View File

@ -91,7 +91,7 @@ public class RebaseIfNecessary extends SubmitStrategy {
rebaseChange.rebase(args.repo, args.rw, args.inserter,
n.getPatchsetId(), n.change(), uploader,
mergeTip.getCurrentTip(), args.mergeUtil,
args.serverIdent.get(), false, false, ValidatePolicy.NONE);
args.serverIdent.get(), false, ValidatePolicy.NONE);
List<PatchSetApproval> approvals = Lists.newArrayList();
for (PatchSetApproval a : args.approvalsUtil.byPatchSet(args.db,