summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <sop@google.com>2014-12-10 15:54:52 -0800
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2014-12-11 15:10:56 +0000
commit202f02835a0315357b57b02aab6011ddb708dbac (patch)
tree35fa002889f7ff4f42f792184b64eee5be49385e
parentf2082056354a102851f54ee683a86dbba07a8129 (diff)
Do not include project watchers on new draft changes
If a draft change is created by pushing to refs/drafts/master only the reviewers explicitly named on the command line (which may be empty) should be notified of the change. Users watching the project should not be notified, as the change has not yet been published. Change-Id: I703ea779106c025c8002e79d39c060208b2e119d (cherry picked from commit 8690a108f6f63b58496d49c09e1e6ea954c7c7b0)
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/mail/CreateChangeSender.java42
1 files changed, 22 insertions, 20 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/mail/CreateChangeSender.java b/gerrit-server/src/main/java/com/google/gerrit/server/mail/CreateChangeSender.java
index 3c9f39c01e..f570ac8253 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/mail/CreateChangeSender.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/mail/CreateChangeSender.java
@@ -45,30 +45,32 @@ public class CreateChangeSender extends NewChangeSender {
protected void init() throws EmailException {
super.init();
- try {
- // Try to mark interested owners with TO and CC or BCC line.
- Watchers matching = getWatchers(NotifyType.NEW_CHANGES);
- for (Account.Id user : Iterables.concat(
- matching.to.accounts,
- matching.cc.accounts,
- matching.bcc.accounts)) {
- if (isOwnerOfProjectOrBranch(user)) {
- add(RecipientType.TO, user);
+ if (change.getStatus() == Change.Status.NEW) {
+ try {
+ // Try to mark interested owners with TO and CC or BCC line.
+ Watchers matching = getWatchers(NotifyType.NEW_CHANGES);
+ for (Account.Id user : Iterables.concat(
+ matching.to.accounts,
+ matching.cc.accounts,
+ matching.bcc.accounts)) {
+ if (isOwnerOfProjectOrBranch(user)) {
+ add(RecipientType.TO, user);
+ }
}
+
+ // Add everyone else. Owners added above will not be duplicated.
+ add(RecipientType.TO, matching.to);
+ add(RecipientType.CC, matching.cc);
+ add(RecipientType.BCC, matching.bcc);
+ } catch (OrmException err) {
+ // Just don't CC everyone. Better to send a partial message to those
+ // we already have queued up then to fail deliver entirely to people
+ // who have a lower interest in the change.
+ log.warn("Cannot notify watchers for new change", err);
}
- // Add everyone else. Owners added above will not be duplicated.
- add(RecipientType.TO, matching.to);
- add(RecipientType.CC, matching.cc);
- add(RecipientType.BCC, matching.bcc);
- } catch (OrmException err) {
- // Just don't CC everyone. Better to send a partial message to those
- // we already have queued up then to fail deliver entirely to people
- // who have a lower interest in the change.
- log.warn("Cannot notify watchers for new change", err);
+ includeWatchers(NotifyType.NEW_PATCHSETS);
}
-
- includeWatchers(NotifyType.NEW_PATCHSETS);
}
private boolean isOwnerOfProjectOrBranch(Account.Id user) {