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): ...@@ -656,7 +656,7 @@ def GetReview(host, change, revision):
return ReadHttpJsonResponse(CreateHttpConn(host, path)) 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.""" """Add reviewers to a change."""
errors = None errors = None
if not add: if not add:
...@@ -666,9 +666,11 @@ def AddReviewers(host, change, add=None, is_reviewer=True): ...@@ -666,9 +666,11 @@ def AddReviewers(host, change, add=None, is_reviewer=True):
path = 'changes/%s/reviewers' % change path = 'changes/%s/reviewers' % change
for r in add: for r in add:
state = 'REVIEWER' if is_reviewer else 'CC' state = 'REVIEWER' if is_reviewer else 'CC'
notify = 'ALL' if notify else 'NONE'
body = { body = {
'reviewer': r, 'reviewer': r,
'state': state, 'state': state,
'notify': notify,
} }
try: try:
conn = CreateHttpConn(host, path, reqtype='POST', body=body) conn = CreateHttpConn(host, path, reqtype='POST', body=body)
......
...@@ -2869,7 +2869,8 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase): ...@@ -2869,7 +2869,8 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
cc.extend(change_desc.get_cced()) cc.extend(change_desc.get_cced())
if cc: if cc:
gerrit_util.AddReviewers( 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 return 0
def _AddChangeIdToCommitMessage(self, options, args): def _AddChangeIdToCommitMessage(self, options, args):
...@@ -4228,7 +4229,7 @@ def CMDupload(parser, args): ...@@ -4228,7 +4229,7 @@ def CMDupload(parser, args):
action='append', default=[], action='append', default=[],
help='cc email addresses') help='cc email addresses')
parser.add_option('-s', '--send-mail', action='store_true', 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', parser.add_option('--emulate_svn_auto_props',
'--emulate-svn-auto-props', '--emulate-svn-auto-props',
action="store_true", action="store_true",
......
...@@ -1361,7 +1361,7 @@ class TestGitCl(TestCase): ...@@ -1361,7 +1361,7 @@ class TestGitCl(TestCase):
((['git', 'config', 'rietveld.cc'],), ''), ((['git', 'config', 'rietveld.cc'],), ''),
((['AddReviewers', 'chromium-review.googlesource.com', ((['AddReviewers', 'chromium-review.googlesource.com',
123456 if squash else None, 123456 if squash else None,
['joe@example.com'] + cc, False],), ''), ['joe@example.com'] + cc, False, notify],), ''),
] ]
calls += cls._git_post_upload_calls() calls += cls._git_post_upload_calls()
return calls return calls
...@@ -1400,8 +1400,8 @@ class TestGitCl(TestCase): ...@@ -1400,8 +1400,8 @@ class TestGitCl(TestCase):
lambda *_, **__: self._mocked_call(['RunEditor'])) lambda *_, **__: self._mocked_call(['RunEditor']))
self.mock(git_cl, 'DownloadGerritHook', self._mocked_call) self.mock(git_cl, 'DownloadGerritHook', self._mocked_call)
self.mock(git_cl.gerrit_util, 'AddReviewers', self.mock(git_cl.gerrit_util, 'AddReviewers',
lambda h, i, add, is_reviewer: self._mocked_call( lambda h, i, add, is_reviewer, notify: self._mocked_call(
['AddReviewers', h, i, add, is_reviewer])) ['AddReviewers', h, i, add, is_reviewer, notify]))
self.calls = self._gerrit_base_calls(issue=issue) self.calls = self._gerrit_base_calls(issue=issue)
self.calls += self._gerrit_upload_calls( 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