From 1aa405fd859a3bd625b0d61184d6e4a3cf95c0b4 Mon Sep 17 00:00:00 2001 From: Sergiy Byelozyorov Date: Tue, 18 Sep 2018 17:38:43 +0000 Subject: [PATCH] Add an option to disable adding CC emails automatically R=ehmaldonado@chromium.org, machenbach@chromium.org Bug: 878303 Change-Id: Ia90001025babe692e481eb74fdbb4a66ce9a22f8 Reviewed-on: https://chromium-review.googlesource.com/1230074 Commit-Queue: Sergiy Byelozyorov Reviewed-by: Michael Achenbach Reviewed-by: Edward Lesmes --- git_cl.py | 22 +++++++++++++--------- tests/git_cl_test.py | 25 ++++++++++++++++++------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/git_cl.py b/git_cl.py index 997d179eb8..2d45e97175 100755 --- a/git_cl.py +++ b/git_cl.py @@ -2261,13 +2261,14 @@ class _RietveldChangelistImpl(_ChangelistCodereviewBase): DieWithError("Must specify reviewers to send email.", change_desc) upload_args.append('--send_mail') - # We check this before applying rietveld.private assuming that in - # rietveld.cc only addresses which we can send private CLs to are listed - # if rietveld.private is set, and so we should ignore rietveld.cc only - # when --private is specified explicitly on the command line. - if options.private: - logging.warn('rietveld.cc is ignored since private flag is specified. ' - 'You need to review and add them manually if necessary.') + # We only skip auto-CC-ing addresses from rietveld.cc when --private or + # --no-autocc is explicitly specified on the command line. Should private + # CL be created due to rietveld.private value, we assume that rietveld.cc + # only contains addresses where private CLs are allowed to be sent. + if options.private or options.no_autocc: + logging.warn('rietveld.cc is ignored since private/no-autocc flag is ' + 'specified. You need to review and add them manually if ' + 'necessary.') cc = self.GetCCListWithoutDefault() else: cc = self.GetCCList() @@ -5094,9 +5095,12 @@ def CMDupload(parser, args): help='Run all tests specified by input_api.RunTests in all ' 'PRESUBMIT files in parallel.') - # TODO: remove Rietveld flags + parser.add_option('--no-autocc', action='store_true', + help='Disables automatic addition of CC emails') parser.add_option('--private', action='store_true', - help='set the review private (rietveld only)') + help='Set the review private. This implies --no-autocc.') + + # TODO: remove Rietveld flags parser.add_option('--email', default=None, help='email address to use to connect to Rietveld') diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index cb20c194cc..1e4b03c20d 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -765,9 +765,9 @@ class TestGitCl(TestCase): ((['git', 'config', 'gerrit.host'],), 'True' if gerrit else '')] @classmethod - def _upload_calls(cls, private): + def _upload_calls(cls, private, no_autocc): return (cls._rietveld_git_base_calls() + - cls._git_upload_calls(private)) + cls._git_upload_calls(private, no_autocc)) @classmethod def _rietveld_upload_no_rev_calls(cls): @@ -809,12 +809,15 @@ class TestGitCl(TestCase): ] @classmethod - def _git_upload_calls(cls, private): - if private: + def _git_upload_calls(cls, private, no_autocc): + if private or no_autocc: cc_call = [] - private_call = [] else: cc_call = [((['git', 'config', 'rietveld.cc'],), '')] + + if private: + private_call = [] + else: private_call = [ ((['git', 'config', 'rietveld.private'],), '')] @@ -887,15 +890,15 @@ class TestGitCl(TestCase): returned_description, final_description, reviewers, - private=False, cc=None): """Generic reviewer test framework.""" self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) private = '--private' in upload_args cc = cc or [] + no_autocc = '--no-autocc' in upload_args - self.calls = self._upload_calls(private) + self.calls = self._upload_calls(private, no_autocc) def RunEditor(desc, _, **kwargs): self.assertEquals( @@ -933,6 +936,14 @@ class TestGitCl(TestCase): 'desc\n\nBUG=', []) + def test_no_autocc(self): + self._run_reviewer_test( + ['--no-autocc'], + 'desc\n\nBUG=', + '# Blah blah comment.\ndesc\n\nBUG=\n', + 'desc\n\nBUG=', + []) + def test_reviewers_cmd_line(self): # Reviewer is passed as-is description = 'desc\n\nR=foo@example.com\nBUG='