Commit 81e3ff52 authored by Yoshisato Yanagisawa's avatar Yoshisato Yanagisawa Committed by Commit Bot

git-cl upload: adjust code-review score on TBR.

Since git-cl TBR always sets +1, it does not allow auto-submit where
using +2 score as approval.  Let me make git-cl automatically adjust
to proper score.

Bug: 762425
Change-Id: I71fe1af1b8bf5e68d2509c60e8bf05024b6bdbb7
Reviewed-on: https://chromium-review.googlesource.com/680717Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
parent 0f09f971
......@@ -149,7 +149,7 @@ def RunGitWithCode(args, suppress_stderr=False):
stderr=stderr)
return code, out
except subprocess2.CalledProcessError as e:
logging.debug('Failed running %s', args)
logging.debug('Failed running %s', ['git'] + args)
return e.returncode, e.stdout
......@@ -3116,10 +3116,15 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
notify=bool(options.send_mail))
if change_desc.get_reviewers(tbr_only=True):
print('Adding self-LGTM (Code-Review +1) because of TBRs.')
labels = self._GetChangeDetail(['LABELS']).get('labels', {})
score = 1
if 'Code-Review' in labels and 'values' in labels['Code-Review']:
score = max([int(x) for x in labels['Code-Review']['values'].keys()])
print('Adding self-LGTM (Code-Review +%d) because of TBRs.' % score)
gerrit_util.SetReview(
self._GetGerritHost(), self.GetIssue(),
msg='Self-approving for TBR', labels={'Code-Review': 1})
msg='Self-approving for TBR',
labels={'Code-Review': score})
return 0
......
......@@ -1617,9 +1617,24 @@ class TestGitCl(TestCase):
]
if tbr:
calls += [
(('GetChangeDetail', 'chromium-review.googlesource.com', '123456',
['LABELS']), {
'labels': {
'Code-Review': {
'default_value': 0,
'all': [],
'values': {
'+2': 'lgtm, approved',
'+1': 'lgtm, but someone else must approve',
' 0': 'No score',
'-1': 'Don\'t submit as-is',
}
}
}
}),
(('SetReview', 'chromium-review.googlesource.com',
123456 if squash else None, 'Self-approving for TBR',
{'Code-Review': 1}, None), ''),
{'Code-Review': 2}, None), ''),
]
calls += cls._git_post_upload_calls()
return calls
......@@ -1743,10 +1758,9 @@ class TestGitCl(TestCase):
[],
'desc\nTBR=reviewer@example.com\nBUG=\nR=another@example.com\n'
'CC=more@example.com,people@example.com\n\n'
'Change-Id: 123456789\n',
'Change-Id: 123456789',
['reviewer@example.com', 'another@example.com'],
squash=False,
squash_mode='override_nosquash',
expected_upstream_ref='origin/master',
cc=['more@example.com', 'people@example.com'],
tbr='reviewer@example.com')
......
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