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.
[email protected]
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
diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py
index f23935b..82a404c 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -758,7 +758,7 @@
@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 @@
# ref_suffix = '%[email protected]'
# else:
# ref_suffix += ',[email protected]'
+
+ notify_suffix = 'notify=%s' % ('ALL' if notify else 'NONE')
+ if ref_suffix:
+ ref_suffix += ',' + notify_suffix
+ else:
+ ref_suffix = '%' + notify_suffix
if reviewers:
- if ref_suffix:
- ref_suffix += ','
- else:
- ref_suffix = '%'
- ref_suffix += ','.join('r=%s' % email for email in sorted(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 @@
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 @@
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 @@
def test_gerrit_reviewers_cmd_line(self):
self._run_gerrit_upload_test(
- ['-r', '[email protected]'],
+ ['-r', '[email protected]', '--send-mail'],
'desc\n\nBUG=\n\nChange-Id: I123456789',
- ['[email protected]'])
+ ['[email protected]'],
+ notify=True)
def test_gerrit_reviewer_multiple(self):
self._run_gerrit_upload_test(