Allow uploader to control who should be notified on upload
A new 'notify' option is added that can be specified on push: git push ssh://bot@gerrit:29418/foo HEAD:refs/for/master%notify=NONE It supports the same values as the notify option in ReviewInput: NONE, OWNER, OWNER_REVIEWERS, ALL This is useful to reduce email noise when bot users are automatically uploading changes and patch sets. E.g. a bot that is able to forge committer and author may want to upload a commit without cc-ing the author and the committer of that commit. Change-Id: I473703a439018c3097f5c3de8f47d3f8371551ab Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
		@@ -22,6 +22,7 @@ import com.google.common.base.MoreObjects;
 | 
			
		||||
import com.google.gerrit.common.ChangeHooks;
 | 
			
		||||
import com.google.gerrit.common.FooterConstants;
 | 
			
		||||
import com.google.gerrit.common.data.LabelTypes;
 | 
			
		||||
import com.google.gerrit.extensions.api.changes.ReviewInput.NotifyHandling;
 | 
			
		||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
 | 
			
		||||
import com.google.gerrit.reviewdb.client.Account;
 | 
			
		||||
import com.google.gerrit.reviewdb.client.Branch;
 | 
			
		||||
@@ -102,6 +103,7 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
 | 
			
		||||
  private Iterable<String> groups;
 | 
			
		||||
  private CommitValidators.Policy validatePolicy =
 | 
			
		||||
      CommitValidators.Policy.GERRIT;
 | 
			
		||||
  private NotifyHandling notify = NotifyHandling.ALL;
 | 
			
		||||
  private Set<Account.Id> reviewers;
 | 
			
		||||
  private Set<Account.Id> extraCC;
 | 
			
		||||
  private Map<String, Short> approvals;
 | 
			
		||||
@@ -206,6 +208,11 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
 | 
			
		||||
    return this;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public ChangeInserter setNotify(NotifyHandling notify) {
 | 
			
		||||
    this.notify = notify;
 | 
			
		||||
    return this;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public ChangeInserter setReviewers(Set<Account.Id> reviewers) {
 | 
			
		||||
    this.reviewers = reviewers;
 | 
			
		||||
    return this;
 | 
			
		||||
@@ -347,6 +354,7 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
 | 
			
		||||
                createChangeSenderFactory.create(change.getId());
 | 
			
		||||
            cm.setFrom(change.getOwner());
 | 
			
		||||
            cm.setPatchSet(patchSet, patchSetInfo);
 | 
			
		||||
            cm.setNotify(notify);
 | 
			
		||||
            cm.addReviewers(reviewers);
 | 
			
		||||
            cm.addExtraCC(extraCC);
 | 
			
		||||
            cm.send();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user