Reland "git cl status: differentiate "dry-run" from generic "commit"."
This is a reland of 3c830222aedad072e0ee6c9feb55214cc24b36f1 with a fix.
Previous CL relied on summary data of CQ votes provided by Gerrit,
which apparently isn't always present in the way I expected.
This resulted in "git cl status" returning "lgtm" instead of "commit"
on Skia recipe roll CLs, which resulted in recipe roller abandoning CLs,
and creating new ones (there might be a bug in recipe roller, too).
The fix is to iterate over all votes on CQ label and finding the highest
score, and then deciding on the state.
Original change's description:
> git cl status: differentiate "dry-run" from generic "commit".
>
> CQ vote now before
> +2 "commit" "commit"
> +1 "dry-run" "commit"
>
> R=ehmaldonado
>
> Tested: manual "git cl status" run locally.
> Change-Id: I342a3ac0830a67bf0e722c737ef00460a0df4b98
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1548287
> Auto-Submit: Andrii Shyshkalov <tandrii@chromium.org>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
> Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Change-Id: If9af5a2bf8f21d203b7a62740a27916eca0838ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1549640
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 59a9af7..2d3b54c 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -2064,6 +2064,7 @@
* 'waiting' - waiting for review
* 'reply' - waiting for uploader to reply to review
* 'lgtm' - Code-Review label has been set
+ * 'dry-run' - dry-running in the commit queue
* 'commit' - in the commit queue
* 'closed' - successfully submitted or abandoned
"""
@@ -2079,10 +2080,14 @@
if data['status'] in ('ABANDONED', 'MERGED'):
return 'closed'
- if data['labels'].get('Commit-Queue', {}).get('approved'):
- # The section will have an "approved" subsection if anyone has voted
- # the maximum value on the label.
+ cq_label = data['labels'].get('Commit-Queue', {})
+ max_cq_vote = 0
+ for vote in cq_label.get('all', []):
+ max_cq_vote = max(max_cq_vote, vote.get('value', 0))
+ if max_cq_vote == 2:
return 'commit'
+ if max_cq_vote == 1:
+ return 'dry-run'
if data['labels'].get('Code-Review', {}).get('approved'):
return 'lgtm'