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 4739 matching lines...) Loading... | |
4750 group.add_option( | 4750 group.add_option( |
4751 "-p", "--patchset", type=int, help="patchset number if not current.") | 4751 "-p", "--patchset", type=int, help="patchset number if not current.") |
4752 group.add_option( | 4752 group.add_option( |
4753 "--print-master", action='store_true', help="print master name as well.") | 4753 "--print-master", action='store_true', help="print master name as well.") |
4754 group.add_option( | 4754 group.add_option( |
4755 "--color", action='store_true', default=setup_color.IS_TTY, | 4755 "--color", action='store_true', default=setup_color.IS_TTY, |
4756 help="force color output, useful when piping output.") | 4756 help="force color output, useful when piping output.") |
4757 group.add_option( | 4757 group.add_option( |
4758 "--buildbucket-host", default='cr-buildbucket.appspot.com', | 4758 "--buildbucket-host", default='cr-buildbucket.appspot.com', |
4759 help="Host of buildbucket. The default host is %default.") | 4759 help="Host of buildbucket. The default host is %default.") |
4760 group.add_option( | |
4761 "--json", action='store_true', default=False, | |
tandrii(chromium)
2016/08/24 11:32:23
no need for default.
qyearsley
2016/08/26 01:56:47
Now changing this to be an option that takes a fil
| |
4762 help="Output try job results as JSON instead of a human-readable format.") | |
tandrii(chromium)
2016/08/24 11:32:23
IMO, change to 'write try job results as JSON to a
qyearsley
2016/08/26 01:56:47
Sounds good.
| |
4760 parser.add_option_group(group) | 4763 parser.add_option_group(group) |
4761 auth.add_auth_options(parser) | 4764 auth.add_auth_options(parser) |
4762 options, args = parser.parse_args(args) | 4765 options, args = parser.parse_args(args) |
4763 if args: | 4766 if args: |
4764 parser.error('Unrecognized args: %s' % ' '.join(args)) | 4767 parser.error('Unrecognized args: %s' % ' '.join(args)) |
4765 | 4768 |
4766 auth_config = auth.extract_auth_config_from_options(options) | 4769 auth_config = auth.extract_auth_config_from_options(options) |
4767 cl = Changelist(auth_config=auth_config) | 4770 cl = Changelist(auth_config=auth_config) |
4768 if not cl.GetIssue(): | 4771 if not cl.GetIssue(): |
4769 parser.error('Need to upload first') | 4772 parser.error('Need to upload first') |
4770 | 4773 |
4771 if not options.patchset: | 4774 if not options.patchset: |
4772 options.patchset = cl.GetMostRecentPatchset() | 4775 options.patchset = cl.GetMostRecentPatchset() |
4773 if options.patchset and options.patchset != cl.GetPatchset(): | 4776 if options.patchset and options.patchset != cl.GetPatchset(): |
4774 print( | 4777 print( |
4775 '\nWARNING Mismatch between local config and server. Did a previous ' | 4778 '\nWARNING Mismatch between local config and server. Did a previous ' |
4776 'upload fail?\ngit-cl try always uses latest patchset from rietveld. ' | 4779 'upload fail?\ngit-cl try always uses latest patchset from rietveld. ' |
4777 'Continuing using\npatchset %s.\n' % options.patchset) | 4780 'Continuing using\npatchset %s.\n' % options.patchset) |
4778 try: | 4781 try: |
4779 jobs = fetch_try_jobs(auth_config, cl, options) | 4782 jobs = fetch_try_jobs(auth_config, cl, options) |
4780 except BuildbucketResponseException as ex: | 4783 except BuildbucketResponseException as ex: |
4781 print('Buildbucket error: %s' % ex) | 4784 print('Buildbucket error: %s' % ex) |
4782 return 1 | 4785 return 1 |
4783 except Exception as e: | 4786 except Exception as e: |
4784 stacktrace = (''.join(traceback.format_stack()) + traceback.format_exc()) | 4787 stacktrace = (''.join(traceback.format_stack()) + traceback.format_exc()) |
4785 print('ERROR: Exception when trying to fetch tryjobs: %s\n%s' % | 4788 print('ERROR: Exception when trying to fetch tryjobs: %s\n%s' % |
4786 (e, stacktrace)) | 4789 (e, stacktrace)) |
4787 return 1 | 4790 return 1 |
4788 print_tryjobs(options, jobs) | 4791 if options.json: |
4792 print(json.dumps(jobs, indent=2)) | |
tandrii(chromium)
2016/08/24 11:32:23
hm, you want to dump the *whole* metadata? i don't
| |
4793 else: | |
4794 print_tryjobs(options, jobs) | |
4789 return 0 | 4795 return 0 |
4790 | 4796 |
4791 | 4797 |
4792 @subcommand.usage('[new upstream branch]') | 4798 @subcommand.usage('[new upstream branch]') |
4793 def CMDupstream(parser, args): | 4799 def CMDupstream(parser, args): |
4794 """Prints or sets the name of the upstream branch, if any.""" | 4800 """Prints or sets the name of the upstream branch, if any.""" |
4795 _, args = parser.parse_args(args) | 4801 _, args = parser.parse_args(args) |
4796 if len(args) > 1: | 4802 if len(args) > 1: |
4797 parser.error('Unrecognized args: %s' % ' '.join(args)) | 4803 parser.error('Unrecognized args: %s' % ' '.join(args)) |
4798 | 4804 |
(...skipping 419 matching lines...) Loading... | |
5218 if __name__ == '__main__': | 5224 if __name__ == '__main__': |
5219 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5225 # These affect sys.stdout so do it outside of main() to simplify mocks in |
5220 # unit testing. | 5226 # unit testing. |
5221 fix_encoding.fix_encoding() | 5227 fix_encoding.fix_encoding() |
5222 setup_color.init() | 5228 setup_color.init() |
5223 try: | 5229 try: |
5224 sys.exit(main(sys.argv[1:])) | 5230 sys.exit(main(sys.argv[1:])) |
5225 except KeyboardInterrupt: | 5231 except KeyboardInterrupt: |
5226 sys.stderr.write('interrupted\n') | 5232 sys.stderr.write('interrupted\n') |
5227 sys.exit(1) | 5233 sys.exit(1) |
OLD | NEW |