| 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 3253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3264 - Red not sent for review or broken | 3264 - Red not sent for review or broken |
| 3265 - Blue waiting for review | 3265 - Blue waiting for review |
| 3266 - Yellow waiting for you to reply to review | 3266 - Yellow waiting for you to reply to review |
| 3267 - Green LGTM'ed | 3267 - Green LGTM'ed |
| 3268 - Magenta in the commit queue | 3268 - Magenta in the commit queue |
| 3269 - Cyan was committed, branch can be deleted | 3269 - Cyan was committed, branch can be deleted |
| 3270 | 3270 |
| 3271 Also see 'git cl comments'. | 3271 Also see 'git cl comments'. |
| 3272 """ | 3272 """ |
| 3273 parser.add_option('--field', | 3273 parser.add_option('--field', |
| 3274 help='print only specific field (desc|id|patch|url)') | 3274 help='print only specific field (desc|id|patch|status|url)') |
| 3275 parser.add_option('-f', '--fast', action='store_true', | 3275 parser.add_option('-f', '--fast', action='store_true', |
| 3276 help='Do not retrieve review status') | 3276 help='Do not retrieve review status') |
| 3277 parser.add_option( | 3277 parser.add_option( |
| 3278 '-j', '--maxjobs', action='store', type=int, | 3278 '-j', '--maxjobs', action='store', type=int, |
| 3279 help='The maximum number of jobs to use when retrieving review status') | 3279 help='The maximum number of jobs to use when retrieving review status') |
| 3280 | 3280 |
| 3281 auth.add_auth_options(parser) | 3281 auth.add_auth_options(parser) |
| 3282 options, args = parser.parse_args(args) | 3282 options, args = parser.parse_args(args) |
| 3283 if args: | 3283 if args: |
| 3284 parser.error('Unsupported args: %s' % args) | 3284 parser.error('Unsupported args: %s' % args) |
| 3285 auth_config = auth.extract_auth_config_from_options(options) | 3285 auth_config = auth.extract_auth_config_from_options(options) |
| 3286 | 3286 |
| 3287 if options.field: | 3287 if options.field: |
| 3288 cl = Changelist(auth_config=auth_config) | 3288 cl = Changelist(auth_config=auth_config) |
| 3289 if options.field.startswith('desc'): | 3289 if options.field.startswith('desc'): |
| 3290 print(cl.GetDescription()) | 3290 print(cl.GetDescription()) |
| 3291 elif options.field == 'id': | 3291 elif options.field == 'id': |
| 3292 issueid = cl.GetIssue() | 3292 issueid = cl.GetIssue() |
| 3293 if issueid: | 3293 if issueid: |
| 3294 print(issueid) | 3294 print(issueid) |
| 3295 elif options.field == 'patch': | 3295 elif options.field == 'patch': |
| 3296 patchset = cl.GetPatchset() | 3296 patchset = cl.GetPatchset() |
| 3297 if patchset: | 3297 if patchset: |
| 3298 print(patchset) | 3298 print(patchset) |
| 3299 elif options.field == 'status': |
| 3300 print(cl.GetStatus()) |
| 3299 elif options.field == 'url': | 3301 elif options.field == 'url': |
| 3300 url = cl.GetIssueURL() | 3302 url = cl.GetIssueURL() |
| 3301 if url: | 3303 if url: |
| 3302 print(url) | 3304 print(url) |
| 3303 return 0 | 3305 return 0 |
| 3304 | 3306 |
| 3305 branches = RunGit(['for-each-ref', '--format=%(refname)', 'refs/heads']) | 3307 branches = RunGit(['for-each-ref', '--format=%(refname)', 'refs/heads']) |
| 3306 if not branches: | 3308 if not branches: |
| 3307 print('No local branch found.') | 3309 print('No local branch found.') |
| 3308 return 0 | 3310 return 0 |
| (...skipping 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5103 if __name__ == '__main__': | 5105 if __name__ == '__main__': |
| 5104 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5106 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 5105 # unit testing. | 5107 # unit testing. |
| 5106 fix_encoding.fix_encoding() | 5108 fix_encoding.fix_encoding() |
| 5107 setup_color.init() | 5109 setup_color.init() |
| 5108 try: | 5110 try: |
| 5109 sys.exit(main(sys.argv[1:])) | 5111 sys.exit(main(sys.argv[1:])) |
| 5110 except KeyboardInterrupt: | 5112 except KeyboardInterrupt: |
| 5111 sys.stderr.write('interrupted\n') | 5113 sys.stderr.write('interrupted\n') |
| 5112 sys.exit(1) | 5114 sys.exit(1) |
| OLD | NEW |