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/680717
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index f65f7b2..7c993bb 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -149,7 +149,7 @@
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 @@
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