Gerrit git cl upload: obey -s --send-mail option.

Previously, git cl upload would send email every time.
This CL changes that to send email only if -s or --send-mail is given.

R=andybons@chromium.org
BUG=612728

Review-Url: https://codereview.chromium.org/2007873002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@300662 0039d316-1c4b-4281-b951-d872f2087c98
changes/30/350330/1
tandrii@chromium.org 9 years ago
parent 6116238a48
commit 8da4540381

@ -2468,6 +2468,13 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
print('WARNING: underscores in title will be converted to spaces.')
refspec_opts.append('m=' + options.title.replace(' ', '_'))
if options.send_mail:
if not change_desc.get_reviewers():
DieWithError('Must specify reviewers to send email.')
refspec_opts.append('notify=ALL')
else:
refspec_opts.append('notify=NONE')
cc = self.GetCCList().split(',')
if options.cc:
cc.extend(options.cc)
@ -2482,7 +2489,6 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
refspec_opts.extend('r=' + email.strip()
for email in change_desc.get_reviewers())
refspec_suffix = ''
if refspec_opts:
refspec_suffix = '%' + ','.join(refspec_opts)

@ -758,7 +758,7 @@ class TestGitCl(TestCase):
@classmethod
def _gerrit_upload_calls(cls, description, reviewers, squash,
expected_upstream_ref='origin/refs/heads/master',
ref_suffix='',
ref_suffix='', notify=False,
post_amend_description=None, issue=None):
if post_amend_description is None:
post_amend_description = description
@ -827,12 +827,15 @@ class TestGitCl(TestCase):
# ref_suffix = '%cc=joe@example.com'
# else:
# ref_suffix += ',cc=joe@example.com'
if reviewers:
notify_suffix = 'notify=%s' % ('ALL' if notify else 'NONE')
if ref_suffix:
ref_suffix += ','
ref_suffix += ',' + notify_suffix
else:
ref_suffix = '%'
ref_suffix += ','.join('r=%s' % email for email in sorted(reviewers))
ref_suffix = '%' + notify_suffix
if reviewers:
ref_suffix += ',' + ','.join('r=%s' % email
for email in sorted(reviewers))
calls += [
((['git', 'push', 'origin',
ref_to_push + ':refs/for/refs/heads/master' + ref_suffix],),
@ -869,6 +872,7 @@ class TestGitCl(TestCase):
squash=False,
expected_upstream_ref='origin/refs/heads/master',
ref_suffix='',
notify=False,
post_amend_description=None,
issue=None):
"""Generic gerrit upload test framework."""
@ -880,7 +884,7 @@ class TestGitCl(TestCase):
self.calls += self._gerrit_upload_calls(
description, reviewers, squash,
expected_upstream_ref=expected_upstream_ref,
ref_suffix=ref_suffix,
ref_suffix=ref_suffix, notify=notify,
post_amend_description=post_amend_description,
issue=issue)
# Uncomment when debugging.
@ -909,9 +913,10 @@ class TestGitCl(TestCase):
def test_gerrit_reviewers_cmd_line(self):
self._run_gerrit_upload_test(
['-r', 'foo@example.com'],
['-r', 'foo@example.com', '--send-mail'],
'desc\n\nBUG=\n\nChange-Id: I123456789',
['foo@example.com'])
['foo@example.com'],
notify=True)
def test_gerrit_reviewer_multiple(self):
self._run_gerrit_upload_test(

Loading…
Cancel
Save