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 distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
(...skipping 3239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3250 color, message['date'].split('.', 1)[0], message['sender'], | 3250 color, message['date'].split('.', 1)[0], message['sender'], |
3251 Fore.RESET) | 3251 Fore.RESET) |
3252 if message['text'].strip(): | 3252 if message['text'].strip(): |
3253 print '\n'.join(' ' + l for l in message['text'].splitlines()) | 3253 print '\n'.join(' ' + l for l in message['text'].splitlines()) |
3254 if options.json_file: | 3254 if options.json_file: |
3255 with open(options.json_file, 'wb') as f: | 3255 with open(options.json_file, 'wb') as f: |
3256 json.dump(summary, f) | 3256 json.dump(summary, f) |
3257 return 0 | 3257 return 0 |
3258 | 3258 |
3259 | 3259 |
3260 @subcommand.usage('[codereview url or issue id]') | |
3260 def CMDdescription(parser, args): | 3261 def CMDdescription(parser, args): |
3261 """Brings up the editor for the current CL's description.""" | 3262 """Brings up the editor for the current CL's description.""" |
3262 parser.add_option('-d', '--display', action='store_true', | 3263 parser.add_option('-d', '--display', action='store_true', |
3263 help='Display the description instead of opening an editor') | 3264 help='Display the description instead of opening an editor') |
3265 | |
3266 _add_codereview_select_options(parser) | |
3264 auth.add_auth_options(parser) | 3267 auth.add_auth_options(parser) |
3265 options, _ = parser.parse_args(args) | 3268 options, args = parser.parse_args(args) |
3269 _process_codereview_select_options(parser, options) | |
3270 | |
3271 target_issue = None | |
3272 if len(args) > 0: | |
3273 issue_arg = ParseIssueNumberArgument(args[0]) | |
3274 if not issue_arg.valid: | |
3275 parser.print_help() | |
3276 return 1 | |
3277 target_issue = issue_arg.issue | |
3278 | |
3266 auth_config = auth.extract_auth_config_from_options(options) | 3279 auth_config = auth.extract_auth_config_from_options(options) |
3267 cl = Changelist(auth_config=auth_config) | 3280 |
3281 cl = Changelist( | |
3282 auth_config=auth_config, issue=target_issue, | |
3283 codereview=options.forced_codereview) | |
3284 | |
3268 if not cl.GetIssue(): | 3285 if not cl.GetIssue(): |
3269 DieWithError('This branch has no associated changelist.') | 3286 DieWithError('This branch has no associated changelist.') |
3270 description = ChangeDescription(cl.GetDescription()) | 3287 description = ChangeDescription(cl.GetDescription()) |
3271 if options.display: | 3288 if options.display: |
3272 print description.description | 3289 print >> sys.stdout, description.description |
tandrii(chromium)
2016/04/26 10:34:20
well, but print always goes to sys.stdout, so i fi
| |
3273 return 0 | 3290 return 0 |
3274 description.prompt() | 3291 description.prompt() |
3275 if cl.GetDescription() != description.description: | 3292 if cl.GetDescription() != description.description: |
3276 cl.UpdateDescription(description.description) | 3293 cl.UpdateDescription(description.description) |
3277 return 0 | 3294 return 0 |
3278 | 3295 |
3279 | 3296 |
3280 def CreateDescriptionFromLog(args): | 3297 def CreateDescriptionFromLog(args): |
3281 """Pulls out the commit log to use as a base for the CL description.""" | 3298 """Pulls out the commit log to use as a base for the CL description.""" |
3282 log_args = [] | 3299 log_args = [] |
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4830 if __name__ == '__main__': | 4847 if __name__ == '__main__': |
4831 # These affect sys.stdout so do it outside of main() to simplify mocks in | 4848 # These affect sys.stdout so do it outside of main() to simplify mocks in |
4832 # unit testing. | 4849 # unit testing. |
4833 fix_encoding.fix_encoding() | 4850 fix_encoding.fix_encoding() |
4834 setup_color.init() | 4851 setup_color.init() |
4835 try: | 4852 try: |
4836 sys.exit(main(sys.argv[1:])) | 4853 sys.exit(main(sys.argv[1:])) |
4837 except KeyboardInterrupt: | 4854 except KeyboardInterrupt: |
4838 sys.stderr.write('interrupted\n') | 4855 sys.stderr.write('interrupted\n') |
4839 sys.exit(1) | 4856 sys.exit(1) |
OLD | NEW |