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

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: Simplified a lot yay. 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') | tests/git_cl_test.py » ('J')
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 3234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3245 color, message['date'].split('.', 1)[0], message['sender'], 3245 color, message['date'].split('.', 1)[0], message['sender'],
3246 Fore.RESET) 3246 Fore.RESET)
3247 if message['text'].strip(): 3247 if message['text'].strip():
3248 print '\n'.join(' ' + l for l in message['text'].splitlines()) 3248 print '\n'.join(' ' + l for l in message['text'].splitlines())
3249 if options.json_file: 3249 if options.json_file:
3250 with open(options.json_file, 'wb') as f: 3250 with open(options.json_file, 'wb') as f:
3251 json.dump(summary, f) 3251 json.dump(summary, f)
3252 return 0 3252 return 0
3253 3253
3254 3254
3255 @subcommand.usage('<codereview url or issue id>')
tandrii(chromium) 2016/04/19 09:42:04 wrap in [] to indicate optionality. by default, is
martiniss 2016/04/25 22:33:06 Done.
3255 def CMDdescription(parser, args): 3256 def CMDdescription(parser, args):
3256 """Brings up the editor for the current CL's description.""" 3257 """Brings up the editor for the current CL's description."""
3257 parser.add_option('-d', '--display', action='store_true', 3258 parser.add_option('-d', '--display', action='store_true',
3258 help='Display the description instead of opening an editor') 3259 help='Display the description instead of opening an editor')
3260 parser.add_option('-i', '--issue',
tandrii(chromium) 2016/04/19 09:42:04 this contradicts the help above. IMO, choose eithe
martiniss 2016/04/25 22:33:06 Removed.
3261 help='The issue to act on the description of')
3262
3263 _add_codereview_select_options(parser)
3259 auth.add_auth_options(parser) 3264 auth.add_auth_options(parser)
3260 options, _ = parser.parse_args(args) 3265 options, args = parser.parse_args(args)
3266 _process_codereview_select_options(parser, options)
3267
3268 target_issue = None
3269 if options.issue:
3270 issue_arg = ParseIssueNumberArgument(options.issue)
3271 if not issue_arg.valid:
3272 parser.print_help()
3273 return 1
3274 target_issue = issue_arg.issue
tandrii(chromium) 2016/04/19 09:42:04 you are potentially disregarding the codereview se
3275
3261 auth_config = auth.extract_auth_config_from_options(options) 3276 auth_config = auth.extract_auth_config_from_options(options)
3262 cl = Changelist(auth_config=auth_config) 3277 kwargs = {
3278 'auth_config': auth_config,
3279 'issue': target_issue,
3280 'codereview': options.forced_codereview,
3281 }
3282
3283 cl = Changelist(**kwargs)
tandrii(chromium) 2016/04/19 09:42:04 you don't need kwargs var any more.
martiniss 2016/04/25 22:33:06 Fixed.
3263 if not cl.GetIssue(): 3284 if not cl.GetIssue():
3264 DieWithError('This branch has no associated changelist.') 3285 DieWithError('This branch has no associated changelist.')
3265 description = ChangeDescription(cl.GetDescription()) 3286 description = ChangeDescription(cl.GetDescription())
3266 if options.display: 3287 if options.display:
3267 print description.description 3288 print >> sys.stdout, description.description
tandrii(chromium) 2016/04/19 09:42:04 debug leftover?
martiniss 2016/04/25 22:33:06 No, you need this to be able to mock it in the tes
3268 return 0 3289 return 0
3269 description.prompt() 3290 description.prompt()
3270 if cl.GetDescription() != description.description: 3291 if cl.GetDescription() != description.description:
3271 cl.UpdateDescription(description.description) 3292 cl.UpdateDescription(description.description)
3272 return 0 3293 return 0
3273 3294
3274 3295
3275 def CreateDescriptionFromLog(args): 3296 def CreateDescriptionFromLog(args):
3276 """Pulls out the commit log to use as a base for the CL description.""" 3297 """Pulls out the commit log to use as a base for the CL description."""
3277 log_args = [] 3298 log_args = []
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after
4825 if __name__ == '__main__': 4846 if __name__ == '__main__':
4826 # These affect sys.stdout so do it outside of main() to simplify mocks in 4847 # These affect sys.stdout so do it outside of main() to simplify mocks in
4827 # unit testing. 4848 # unit testing.
4828 fix_encoding.fix_encoding() 4849 fix_encoding.fix_encoding()
4829 setup_color.init() 4850 setup_color.init()
4830 try: 4851 try:
4831 sys.exit(main(sys.argv[1:])) 4852 sys.exit(main(sys.argv[1:]))
4832 except KeyboardInterrupt: 4853 except KeyboardInterrupt:
4833 sys.stderr.write('interrupted\n') 4854 sys.stderr.write('interrupted\n')
4834 sys.exit(1) 4855 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | tests/git_cl_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698