OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
7 | 7 |
8 """A git-command for integrating reviews on Rietveld and Gerrit.""" | 8 """A git-command for integrating reviews on Rietveld and Gerrit.""" |
9 | 9 |
10 from __future__ import print_function | 10 from __future__ import print_function |
(...skipping 2319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2330 try: | 2330 try: |
2331 data = self._GetChangeDetail(['DETAILED_LABELS', 'CURRENT_REVISION']) | 2331 data = self._GetChangeDetail(['DETAILED_LABELS', 'CURRENT_REVISION']) |
2332 except (httplib.HTTPException, GerritIssueNotExists): | 2332 except (httplib.HTTPException, GerritIssueNotExists): |
2333 return 'error' | 2333 return 'error' |
2334 | 2334 |
2335 if data['status'] in ('ABANDONED', 'MERGED'): | 2335 if data['status'] in ('ABANDONED', 'MERGED'): |
2336 return 'closed' | 2336 return 'closed' |
2337 | 2337 |
2338 cq_label = data['labels'].get('Commit-Queue', {}) | 2338 cq_label = data['labels'].get('Commit-Queue', {}) |
2339 if cq_label: | 2339 if cq_label: |
2340 # Vote value is a stringified integer, which we expect from 0 to 2. | 2340 votes = cq_label.get('all', []) |
2341 vote_value = cq_label.get('value', '0') | 2341 highest_vote = 0 |
| 2342 for v in votes: |
| 2343 highest_vote = max(highest_vote, v.get('value', 0)) |
| 2344 vote_value = str(highest_vote) |
| 2345 if vote_value != '0': |
| 2346 # Add a '+' if the value is not 0 to match the values in the label. |
| 2347 # The cq_label does not have negatives. |
| 2348 vote_value = '+' + vote_value |
2342 vote_text = cq_label.get('values', {}).get(vote_value, '') | 2349 vote_text = cq_label.get('values', {}).get(vote_value, '') |
2343 if vote_text.lower() == 'commit': | 2350 if vote_text.lower() == 'commit': |
2344 return 'commit' | 2351 return 'commit' |
2345 | 2352 |
2346 lgtm_label = data['labels'].get('Code-Review', {}) | 2353 lgtm_label = data['labels'].get('Code-Review', {}) |
2347 if lgtm_label: | 2354 if lgtm_label: |
2348 if 'rejected' in lgtm_label: | 2355 if 'rejected' in lgtm_label: |
2349 return 'not lgtm' | 2356 return 'not lgtm' |
2350 if 'approved' in lgtm_label: | 2357 if 'approved' in lgtm_label: |
2351 return 'lgtm' | 2358 return 'lgtm' |
(...skipping 3013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5365 if __name__ == '__main__': | 5372 if __name__ == '__main__': |
5366 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5373 # These affect sys.stdout so do it outside of main() to simplify mocks in |
5367 # unit testing. | 5374 # unit testing. |
5368 fix_encoding.fix_encoding() | 5375 fix_encoding.fix_encoding() |
5369 setup_color.init() | 5376 setup_color.init() |
5370 try: | 5377 try: |
5371 sys.exit(main(sys.argv[1:])) | 5378 sys.exit(main(sys.argv[1:])) |
5372 except KeyboardInterrupt: | 5379 except KeyboardInterrupt: |
5373 sys.stderr.write('interrupted\n') | 5380 sys.stderr.write('interrupted\n') |
5374 sys.exit(1) | 5381 sys.exit(1) |
OLD | NEW |