Commit 59f48517 authored by Aaron Gable's avatar Aaron Gable Committed by Commit Bot

Don't send email to CCs by default on initial upload

It looks like this regressed when we switched from specifying CCs
via the refspec arguments to using the API.

BUG=680605

Change-Id: Iabd397b639989f050932188b1a1aa488639ffbbe
Reviewed-on: https://chromium-review.googlesource.com/427344Reviewed-by: 's avatarAndrew Bonventre <andybons@chromium.org>
Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
parent 5ededcb5
......@@ -656,7 +656,7 @@ def GetReview(host, change, revision):
return ReadHttpJsonResponse(CreateHttpConn(host, path))
def AddReviewers(host, change, add=None, is_reviewer=True):
def AddReviewers(host, change, add=None, is_reviewer=True, notify=True):
"""Add reviewers to a change."""
errors = None
if not add:
......@@ -666,9 +666,11 @@ def AddReviewers(host, change, add=None, is_reviewer=True):
path = 'changes/%s/reviewers' % change
for r in add:
state = 'REVIEWER' if is_reviewer else 'CC'
notify = 'ALL' if notify else 'NONE'
body = {
'reviewer': r,
'state': state,
'notify': notify,
}
try:
conn = CreateHttpConn(host, path, reqtype='POST', body=body)
......
......@@ -2869,7 +2869,8 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
cc.extend(change_desc.get_cced())
if cc:
gerrit_util.AddReviewers(
self._GetGerritHost(), self.GetIssue(), cc, is_reviewer=False)
self._GetGerritHost(), self.GetIssue(), cc,
is_reviewer=False, notify=bool(options.send_mail))
return 0
def _AddChangeIdToCommitMessage(self, options, args):
......@@ -4228,7 +4229,7 @@ def CMDupload(parser, args):
action='append', default=[],
help='cc email addresses')
parser.add_option('-s', '--send-mail', action='store_true',
help='send email to reviewer immediately')
help='send email to reviewer(s) and cc(s) immediately')
parser.add_option('--emulate_svn_auto_props',
'--emulate-svn-auto-props',
action="store_true",
......
......@@ -1361,7 +1361,7 @@ class TestGitCl(TestCase):
((['git', 'config', 'rietveld.cc'],), ''),
((['AddReviewers', 'chromium-review.googlesource.com',
123456 if squash else None,
['joe@example.com'] + cc, False],), ''),
['joe@example.com'] + cc, False, notify],), ''),
]
calls += cls._git_post_upload_calls()
return calls
......@@ -1400,8 +1400,8 @@ class TestGitCl(TestCase):
lambda *_, **__: self._mocked_call(['RunEditor']))
self.mock(git_cl, 'DownloadGerritHook', self._mocked_call)
self.mock(git_cl.gerrit_util, 'AddReviewers',
lambda h, i, add, is_reviewer: self._mocked_call(
['AddReviewers', h, i, add, is_reviewer]))
lambda h, i, add, is_reviewer, notify: self._mocked_call(
['AddReviewers', h, i, add, is_reviewer, notify]))
self.calls = self._gerrit_base_calls(issue=issue)
self.calls += self._gerrit_upload_calls(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment