Merge "Prevent new patchset notification emails for trivial rebase"
This commit is contained in:
commit
a34ecbed8e
@ -228,6 +228,7 @@ public class CherryPickChange {
|
|||||||
.setMessage("Uploaded patch set " + newPatchSetId.get() + ".")
|
.setMessage("Uploaded patch set " + newPatchSetId.get() + ".")
|
||||||
.setDraft(current.isDraft())
|
.setDraft(current.isDraft())
|
||||||
.setUploader(identifiedUser.getAccountId())
|
.setUploader(identifiedUser.getAccountId())
|
||||||
|
.setSendMail(false)
|
||||||
.insert();
|
.insert();
|
||||||
return change.getId();
|
return change.getId();
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ public class RebaseChange {
|
|||||||
rebase(git, rw, inserter, patchSetId, change,
|
rebase(git, rw, inserter, patchSetId, change,
|
||||||
uploader, baseCommit, mergeUtilFactory.create(
|
uploader, baseCommit, mergeUtilFactory.create(
|
||||||
changeControl.getProjectControl().getProjectState(), true),
|
changeControl.getProjectControl().getProjectState(), true),
|
||||||
committerIdent, true, true, ValidatePolicy.GERRIT);
|
committerIdent, true, ValidatePolicy.GERRIT);
|
||||||
} catch (MergeConflictException e) {
|
} catch (MergeConflictException e) {
|
||||||
throw new IOException(e.getMessage());
|
throw new IOException(e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
@ -265,7 +265,6 @@ public class RebaseChange {
|
|||||||
* @param baseCommit the commit that should be the new base
|
* @param baseCommit the commit that should be the new base
|
||||||
* @param mergeUtil merge utilities for the destination project
|
* @param mergeUtil merge utilities for the destination project
|
||||||
* @param committerIdent the committer's identity
|
* @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 runHooks if hooks should be run for the new patch set
|
||||||
* @param validate if commit validation 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
|
* @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 ObjectInserter inserter, final PatchSet.Id patchSetId,
|
||||||
final Change change, final IdentifiedUser uploader, final RevCommit baseCommit,
|
final Change change, final IdentifiedUser uploader, final RevCommit baseCommit,
|
||||||
final MergeUtil mergeUtil, PersonIdent committerIdent,
|
final MergeUtil mergeUtil, PersonIdent committerIdent,
|
||||||
boolean sendMail, boolean runHooks, ValidatePolicy validate)
|
boolean runHooks, ValidatePolicy validate)
|
||||||
throws NoSuchChangeException,
|
throws NoSuchChangeException,
|
||||||
OrmException, IOException, InvalidChangeOperationException,
|
OrmException, IOException, InvalidChangeOperationException,
|
||||||
MergeConflictException {
|
MergeConflictException {
|
||||||
@ -303,7 +302,7 @@ public class RebaseChange {
|
|||||||
.setValidatePolicy(validate)
|
.setValidatePolicy(validate)
|
||||||
.setDraft(originalPatchSet.isDraft())
|
.setDraft(originalPatchSet.isDraft())
|
||||||
.setUploader(uploader.getAccountId())
|
.setUploader(uploader.getAccountId())
|
||||||
.setSendMail(sendMail)
|
.setSendMail(false)
|
||||||
.setRunHooks(runHooks);
|
.setRunHooks(runHooks);
|
||||||
|
|
||||||
final PatchSet.Id newPatchSetId = patchSetInserter.getPatchSetId();
|
final PatchSet.Id newPatchSetId = patchSetInserter.getPatchSetId();
|
||||||
|
@ -1985,14 +1985,12 @@ public class ReceiveCommits {
|
|||||||
return Futures.makeChecked(future, INSERT_EXCEPTION);
|
return Futures.makeChecked(future, INSERT_EXCEPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChangeMessage newChangeMessage(ReviewDb db) throws OrmException {
|
private ChangeMessage newChangeMessage(ReviewDb db, ChangeKind changeKind)
|
||||||
|
throws OrmException {
|
||||||
msg =
|
msg =
|
||||||
new ChangeMessage(new ChangeMessage.Key(change.getId(), ChangeUtil
|
new ChangeMessage(new ChangeMessage.Key(change.getId(), ChangeUtil
|
||||||
.messageUUID(db)), currentUser.getAccountId(), newPatchSet.getCreatedOn(),
|
.messageUUID(db)), currentUser.getAccountId(), newPatchSet.getCreatedOn(),
|
||||||
newPatchSet.getId());
|
newPatchSet.getId());
|
||||||
RevCommit priorCommit = revisions.inverse().get(priorPatchSet);
|
|
||||||
ChangeKind changeKind = changeKindCache.getChangeKind(
|
|
||||||
projectControl.getProjectState(), repo, priorCommit, newCommit);
|
|
||||||
String message = "Uploaded patch set " + newPatchSet.getPatchSetId();
|
String message = "Uploaded patch set " + newPatchSet.getPatchSetId();
|
||||||
switch (changeKind) {
|
switch (changeKind) {
|
||||||
case TRIVIAL_REBASE:
|
case TRIVIAL_REBASE:
|
||||||
@ -2032,6 +2030,7 @@ public class ReceiveCommits {
|
|||||||
recipients.remove(me);
|
recipients.remove(me);
|
||||||
|
|
||||||
db.changes().beginTransaction(change.getId());
|
db.changes().beginTransaction(change.getId());
|
||||||
|
ChangeKind changeKind = ChangeKind.REWORK;
|
||||||
try {
|
try {
|
||||||
change = db.changes().get(change.getId());
|
change = db.changes().get(change.getId());
|
||||||
if (change == null || change.getStatus().isClosed()) {
|
if (change == null || change.getStatus().isClosed()) {
|
||||||
@ -2057,7 +2056,11 @@ public class ReceiveCommits {
|
|||||||
changeCtl, approvals);
|
changeCtl, approvals);
|
||||||
recipients.add(oldRecipients);
|
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) {
|
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.
|
||||||
@ -2119,6 +2122,7 @@ public class ReceiveCommits {
|
|||||||
cmd.execute(rp);
|
cmd.execute(rp);
|
||||||
}
|
}
|
||||||
CheckedFuture<?, IOException> f = indexer.indexAsync(change.getId());
|
CheckedFuture<?, IOException> f = indexer.indexAsync(change.getId());
|
||||||
|
if (changeKind != ChangeKind.TRIVIAL_REBASE) {
|
||||||
workQueue.getDefaultQueue()
|
workQueue.getDefaultQueue()
|
||||||
.submit(requestScopePropagator.wrap(new Runnable() {
|
.submit(requestScopePropagator.wrap(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -2145,6 +2149,7 @@ public class ReceiveCommits {
|
|||||||
return "send-email newpatchset";
|
return "send-email newpatchset";
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
f.checkedGet();
|
f.checkedGet();
|
||||||
|
|
||||||
gitRefUpdated.fire(project.getNameKey(), newPatchSet.getRefName(),
|
gitRefUpdated.fire(project.getNameKey(), newPatchSet.getRefName(),
|
||||||
|
@ -91,7 +91,7 @@ public class RebaseIfNecessary extends SubmitStrategy {
|
|||||||
rebaseChange.rebase(args.repo, args.rw, args.inserter,
|
rebaseChange.rebase(args.repo, args.rw, args.inserter,
|
||||||
n.getPatchsetId(), n.change(), uploader,
|
n.getPatchsetId(), n.change(), uploader,
|
||||||
mergeTip.getCurrentTip(), args.mergeUtil,
|
mergeTip.getCurrentTip(), args.mergeUtil,
|
||||||
args.serverIdent.get(), false, false, ValidatePolicy.NONE);
|
args.serverIdent.get(), false, ValidatePolicy.NONE);
|
||||||
|
|
||||||
List<PatchSetApproval> approvals = Lists.newArrayList();
|
List<PatchSetApproval> approvals = Lists.newArrayList();
|
||||||
for (PatchSetApproval a : args.approvalsUtil.byPatchSet(args.db,
|
for (PatchSetApproval a : args.approvalsUtil.byPatchSet(args.db,
|
||||||
|
Loading…
Reference in New Issue
Block a user