Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: git_cl.py

Issue 1901733003: git_cl: description fetching from code review servers. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Small whitespace. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3246 matching lines...) Expand 10 before | Expand all | Expand 10 after
3257 color, message['date'].split('.', 1)[0], message['sender'], 3257 color, message['date'].split('.', 1)[0], message['sender'],
3258 Fore.RESET) 3258 Fore.RESET)
3259 if message['text'].strip(): 3259 if message['text'].strip():
3260 print '\n'.join(' ' + l for l in message['text'].splitlines()) 3260 print '\n'.join(' ' + l for l in message['text'].splitlines())
3261 if options.json_file: 3261 if options.json_file:
3262 with open(options.json_file, 'wb') as f: 3262 with open(options.json_file, 'wb') as f:
3263 json.dump(summary, f) 3263 json.dump(summary, f)
3264 return 0 3264 return 0
3265 3265
3266 3266
3267 @subcommand.usage('[codereview url or issue id]')
3267 def CMDdescription(parser, args): 3268 def CMDdescription(parser, args):
3268 """Brings up the editor for the current CL's description.""" 3269 """Brings up the editor for the current CL's description."""
3269 parser.add_option('-d', '--display', action='store_true', 3270 parser.add_option('-d', '--display', action='store_true',
3270 help='Display the description instead of opening an editor') 3271 help='Display the description instead of opening an editor')
3272
3273 _add_codereview_select_options(parser)
3271 auth.add_auth_options(parser) 3274 auth.add_auth_options(parser)
3272 options, _ = parser.parse_args(args) 3275 options, args = parser.parse_args(args)
3276 _process_codereview_select_options(parser, options)
3277
3278 target_issue = None
3279 if len(args) > 0:
3280 issue_arg = ParseIssueNumberArgument(args[0])
3281 if not issue_arg.valid:
3282 parser.print_help()
3283 return 1
3284 target_issue = issue_arg.issue
3285
3273 auth_config = auth.extract_auth_config_from_options(options) 3286 auth_config = auth.extract_auth_config_from_options(options)
3274 cl = Changelist(auth_config=auth_config) 3287
3288 cl = Changelist(
3289 auth_config=auth_config, issue=target_issue,
3290 codereview=options.forced_codereview)
3291
3275 if not cl.GetIssue(): 3292 if not cl.GetIssue():
3276 DieWithError('This branch has no associated changelist.') 3293 DieWithError('This branch has no associated changelist.')
3277 description = ChangeDescription(cl.GetDescription()) 3294 description = ChangeDescription(cl.GetDescription())
3278 if options.display: 3295 if options.display:
3279 print description.description 3296 print >> sys.stdout, description.description
3280 return 0 3297 return 0
3281 description.prompt() 3298 description.prompt()
3282 if cl.GetDescription() != description.description: 3299 if cl.GetDescription() != description.description:
3283 cl.UpdateDescription(description.description) 3300 cl.UpdateDescription(description.description)
3284 return 0 3301 return 0
3285 3302
3286 3303
3287 def CreateDescriptionFromLog(args): 3304 def CreateDescriptionFromLog(args):
3288 """Pulls out the commit log to use as a base for the CL description.""" 3305 """Pulls out the commit log to use as a base for the CL description."""
3289 log_args = [] 3306 log_args = []
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after
4837 if __name__ == '__main__': 4854 if __name__ == '__main__':
4838 # These affect sys.stdout so do it outside of main() to simplify mocks in 4855 # These affect sys.stdout so do it outside of main() to simplify mocks in
4839 # unit testing. 4856 # unit testing.
4840 fix_encoding.fix_encoding() 4857 fix_encoding.fix_encoding()
4841 setup_color.init() 4858 setup_color.init()
4842 try: 4859 try:
4843 sys.exit(main(sys.argv[1:])) 4860 sys.exit(main(sys.argv[1:]))
4844 except KeyboardInterrupt: 4861 except KeyboardInterrupt:
4845 sys.stderr.write('interrupted\n') 4862 sys.stderr.write('interrupted\n')
4846 sys.exit(1) 4863 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698