Commit 99a72f25 authored by tandrii's avatar tandrii Committed by Commit bot

Gerrit git cl upload: self-lgtm on TBR.

BUG=626364
R=andybons@chromium.org
TEST=manual: https://chromium-review.googlesource.com/#/c/372138

Review-Url: https://codereview.chromium.org/2259583002
parent 3c972b90
......@@ -2516,6 +2516,10 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
# Extra options that can be specified at push time. Doc:
# https://gerrit-review.googlesource.com/Documentation/user-upload.html
refspec_opts = []
if change_desc.get_reviewers(tbr_only=True):
print('Adding self-LGTM (Code-Review +1) because of TBRs')
refspec_opts.append('l=Code-Review+1')
if options.title:
if not re.match(r'^[\w ]+$', options.title):
options.title = re.sub(r'[^\w ]', '', options.title)
......@@ -2541,9 +2545,9 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
if cc:
refspec_opts.extend('cc=' + email.strip() for email in cc)
if change_desc.get_reviewers():
refspec_opts.extend('r=' + email.strip()
for email in change_desc.get_reviewers())
reviewers = change_desc.get_reviewers()
if reviewers:
refspec_opts.extend('r=' + email.strip() for email in reviewers)
refspec_suffix = ''
if refspec_opts:
......@@ -2804,10 +2808,12 @@ class ChangeDescription(object):
top_lines.append(line)
self._description_lines = top_lines + separator + gerrit_footers
def get_reviewers(self):
def get_reviewers(self, tbr_only=False):
"""Retrieves the list of reviewers."""
matches = [re.match(self.R_LINE, line) for line in self._description_lines]
reviewers = [match.group(2).strip() for match in matches if match]
reviewers = [match.group(2).strip()
for match in matches
if match and (not tbr_only or match.group(1).upper() == 'TBR')]
return cleanup_list(reviewers)
......
......@@ -288,7 +288,9 @@ class TestGitCl(TestCase):
len(self._calls_done), args, following_calls))
git_cl.logging.error(extended_msg)
self.fail('@%d Expected: %r Actual: %r' % (
self.fail('@%d\n'
' Expected: %r\n'
' Actual: %r' % (
len(self._calls_done), expected_args, args))
self._calls_done.append(top)
......@@ -1003,7 +1005,8 @@ class TestGitCl(TestCase):
'Change-Id: 123456789\n',
['reviewer@example.com', 'another@example.com'],
squash=False,
squash_mode='override_nosquash')
squash_mode='override_nosquash',
ref_suffix='%l=Code-Review+1')
def test_gerrit_upload_squash_first_is_default(self):
# Mock Gerrit CL description to indicate the first upload.
......
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