Automatically CC folks listed in CC= lines.
Detect CC=<users> lines the way we detect R= and TBR=.
Add these as CC'ed users for rietveld and gerrit.
R=iannucci@chromium.org,hinoka@chromium.org,dnj@chromium.org
Review-Url: https://codereview.chromium.org/2433323004
diff --git a/git_cl.py b/git_cl.py
index c78207b..5b0f00a 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -2125,6 +2125,8 @@
else:
cc = self.GetCCList()
cc = ','.join(filter(None, (cc, ','.join(options.cc))))
+ if change_desc.get_cced():
+ cc = ','.join(filter(None, (cc, ','.join(change_desc.get_cced()))))
if cc:
upload_args.extend(['--cc', cc])
@@ -2772,6 +2774,8 @@
if options.cc:
cc.extend(options.cc)
cc = filter(None, [email.strip() for email in cc])
+ if change_desc.get_cced():
+ cc.extend(change_desc.get_cced())
if cc:
gerrit_util.AddReviewers(
self._GetGerritHost(), self.GetIssue(), cc, is_reviewer=False)
@@ -2898,6 +2902,7 @@
class ChangeDescription(object):
"""Contains a parsed form of the change description."""
R_LINE = r'^[ \t]*(TBR|R)[ \t]*=[ \t]*(.*?)[ \t]*$'
+ CC_LINE = r'^[ \t]*(CC)[ \t]*=[ \t]*(.*?)[ \t]*$'
BUG_LINE = r'^[ \t]*(BUG)[ \t]*=[ \t]*(.*?)[ \t]*$'
def __init__(self, description):
@@ -3045,6 +3050,12 @@
if match and (not tbr_only or match.group(1).upper() == 'TBR')]
return cleanup_list(reviewers)
+ def get_cced(self):
+ """Retrieves the list of reviewers."""
+ matches = [re.match(self.CC_LINE, line) for line in self._description_lines]
+ cced = [match.group(2).strip() for match in matches if match]
+ return cleanup_list(cced)
+
def get_approving_reviewers(props):
"""Retrieves the reviewers that approved a CL from the issue properties with