From 99918abbe71b0fd442b4647c80b78c95e1ef78b5 Mon Sep 17 00:00:00 2001 From: "tyoshino@chromium.org" Date: Mon, 30 Sep 2013 06:17:28 +0000 Subject: [PATCH] Ignore CC_LIST when private flag is specified. This prevents private CLs to be automatically CC-ed to public mailing lists unintentionally. Review URL: https://chromiumcodereview.appspot.com/24257014 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@225925 0039d316-1c4b-4281-b951-d872f2087c98 --- gcl.py | 12 +++++++++++- git_cl.py | 21 +++++++++++++++++++-- tests/git_cl_test.py | 5 +++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/gcl.py b/gcl.py index 787226e66..db1e5b3eb 100755 --- a/gcl.py +++ b/gcl.py @@ -878,7 +878,17 @@ def CMDupload(change_info, args): watchlist = watchlists.Watchlists(change_info.GetLocalRoot()) watchers = watchlist.GetWatchersForPaths(change_info.GetFileNames()) - cc_list = GetCodeReviewSetting("CC_LIST") + # We check this before applying the "PRIVATE" parameter of codereview + # settings assuming that the author of the settings file has put + # addresses which we can send private CLs to, and so we should ignore + # CC_LIST only when --private is specified explicitly on the command + # line. + if "--private" in upload_arg: + Warn("WARNING: CC_LIST is ignored since private flag is specified. " + "You need to review and add them manually if necessary.") + cc_list = "" + else: + cc_list = GetCodeReviewSetting("CC_LIST") if not no_watchlists and watchers: # Filter out all empty elements and join by ',' cc_list = ','.join(filter(None, [cc_list] + watchers)) diff --git a/git_cl.py b/git_cl.py index 65e6413cf..ce626ef51 100755 --- a/git_cl.py +++ b/git_cl.py @@ -442,11 +442,17 @@ class Changelist(object): Return is a string suitable for passing to gcl with the --cc flag. """ if self.cc is None: - base_cc = settings .GetDefaultCCList() + base_cc = settings.GetDefaultCCList() more_cc = ','.join(self.watchers) self.cc = ','.join(filter(None, (base_cc, more_cc))) or '' return self.cc + def GetCCListWithoutDefault(self): + """Return the users cc'd on this CL excluding default ones.""" + if self.cc is None: + self.cc = ','.join(self.watchers) + return self.cc + def SetWatchers(self, watchers): """Set the list of email addresses that should be cc'd based on the changed files in this CL. @@ -1421,7 +1427,18 @@ def RietveldUpload(options, args, cl): if not change_desc.get_reviewers(): DieWithError("Must specify reviewers to send email.") upload_args.append('--send_mail') - cc = ','.join(filter(None, (cl.GetCCList(), ','.join(options.cc)))) + + # 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.') + cc = cl.GetCCListWithoutDefault() + else: + cc = cl.GetCCList() + cc = ','.join(filter(None, (cc, ','.join(options.cc)))) if cc: upload_args.extend(['--cc', cc]) diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index 40d181329..23c0c647b 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -188,15 +188,16 @@ class TestGitCl(TestCase): @classmethod def _git_upload_calls(cls, private): if private: + cc_call = [] private_call = [] else: + cc_call = [((['git', 'config', 'rietveld.cc'],), '')] private_call = [ ((['git', 'config', 'rietveld.private'],), '')] return [ ((['git', 'config', 'core.editor'],), ''), - ((['git', 'config', 'rietveld.cc'],), '') - ] + private_call + [ + ] + cc_call + private_call + [ ((['git', 'config', 'branch.master.base-url'],), ''), ((['git', 'config', '--local', '--get-regexp', '^svn-remote\\.'],),