Commit 1aa405fd authored by Sergiy Byelozyorov's avatar Sergiy Byelozyorov Committed by Commit Bot

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 <sergiyb@chromium.org>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
parent 7b54572e
......@@ -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')
......
......@@ -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='
......
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