Chromium Code Reviews

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: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | no next file » | 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 2503 matching lines...)
2514 gerrit_util.SetReview(self._GetGerritHost(), self.GetIssue(), 2514 gerrit_util.SetReview(self._GetGerritHost(), self.GetIssue(),
2515 labels={'Commit-Queue': vote_map[new_state]}) 2515 labels={'Commit-Queue': vote_map[new_state]})
2516 2516
2517 2517
2518 _CODEREVIEW_IMPLEMENTATIONS = { 2518 _CODEREVIEW_IMPLEMENTATIONS = {
2519 'rietveld': _RietveldChangelistImpl, 2519 'rietveld': _RietveldChangelistImpl,
2520 'gerrit': _GerritChangelistImpl, 2520 'gerrit': _GerritChangelistImpl,
2521 } 2521 }
2522 2522
2523 2523
2524 def _add_codereview_select_options(parser): 2524 def _add_codereview_select_options(parser):
tandrii(chromium) 2016/04/18 22:13:16 for consistency, please use this func and the one
2525 """Appends --gerrit and --rietveld options to force specific codereview.""" 2525 """Appends --gerrit and --rietveld options to force specific codereview."""
2526 parser.codereview_group = optparse.OptionGroup( 2526 parser.codereview_group = optparse.OptionGroup(
2527 parser, 'EXPERIMENTAL! Codereview override options') 2527 parser, 'EXPERIMENTAL! Codereview override options')
2528 parser.add_option_group(parser.codereview_group) 2528 parser.add_option_group(parser.codereview_group)
2529 parser.codereview_group.add_option( 2529 parser.codereview_group.add_option(
2530 '--gerrit', action='store_true', 2530 '--gerrit', action='store_true',
2531 help='Force the use of Gerrit for codereview') 2531 help='Force the use of Gerrit for codereview')
2532 parser.codereview_group.add_option( 2532 parser.codereview_group.add_option(
2533 '--rietveld', action='store_true', 2533 '--rietveld', action='store_true',
2534 help='Force the use of Rietveld for codereview') 2534 help='Force the use of Rietveld for codereview')
(...skipping 714 matching lines...)
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 def CMDdescription(parser, args): 3255 def CMDdescription(parser, args):
3256 """Brings up the editor for the current CL's description.""" 3256 """Brings up the editor for the current CL's description."""
3257 parser.add_option('-d', '--display', action='store_true', 3257 parser.add_option('-d', '--display', action='store_true',
3258 help='Display the description instead of opening an editor') 3258 help='Display the description instead of opening an editor')
3259 parser.add_option('-i', '--issue', type=int,
3260 help='The issue to fetch the description from')
tandrii(chromium) 2016/04/18 22:13:16 s/from/from, instead of the current branch issue.
martiniss 2016/04/19 00:18:53 Changed. And made it so you can copy paste a URL.
3261 parser.add_option('--gerrit', action='store_true', default=False,
3262 help='The issue is stored in gerrit')
3263 parser.add_option('--rietveld', action='store_true', default=False,
3264 help='The issue is stored in rietveld')
3265 parser.add_option('-s', '--server',
tandrii(chromium) 2016/04/18 22:13:16 do you actually use this field? If you do, then ma
martiniss 2016/04/19 00:18:53 Removed.
3266 help='The codereview server the issue is stored at')
3267
3259 auth.add_auth_options(parser) 3268 auth.add_auth_options(parser)
3260 options, _ = parser.parse_args(args) 3269 options, _ = parser.parse_args(args)
3270
3271 if options.gerrit and options.rietveld:
tandrii(chromium) 2016/04/18 22:13:16 see _process_codereview_select_options
martiniss 2016/04/19 00:18:53 Done.
3272 DieWithError('only one of --gerrit and --rietveld is allowed')
3273 if not (options.gerrit or options.rietveld) and (
3274 options.issue or options.server):
3275 DieWithError('one of --gerrit and --rietveld is required')
tandrii(chromium) 2016/04/18 22:13:16 why is this so? it wasn't required before. and the
martiniss 2016/04/19 00:18:53 Removed.
3276
3277 codereview = None
3278 if options.gerrit:
3279 codereview = 'gerrit'
3280 if options.rietveld:
3281 codereview = 'rietveld'
3282
3261 auth_config = auth.extract_auth_config_from_options(options) 3283 auth_config = auth.extract_auth_config_from_options(options)
3262 cl = Changelist(auth_config=auth_config) 3284 kwargs = {
3285 'auth_config': auth_config,
3286 'issue': options.issue,
3287 'codereview': codereview,
3288 }
3289
3290 if options.rietveld:
3291 kwargs['rietveld_server'] = options.server
3292 # else nothing, because gerrit guesses the code review from the git host, for
tandrii(chromium) 2016/04/18 22:13:16 so does rietveld, as it's the server is recorded i
martiniss 2016/04/19 00:18:53 Removed.
3293 # now
3294 cl = Changelist(**kwargs)
3263 if not cl.GetIssue(): 3295 if not cl.GetIssue():
3264 DieWithError('This branch has no associated changelist.') 3296 DieWithError('This branch has no associated changelist.')
3265 description = ChangeDescription(cl.GetDescription()) 3297 description = ChangeDescription(cl.GetDescription())
3266 if options.display: 3298 if options.display:
3267 print description.description 3299 print description.description
3268 return 0 3300 return 0
3269 description.prompt() 3301 description.prompt()
3270 if cl.GetDescription() != description.description: 3302 if cl.GetDescription() != description.description:
3271 cl.UpdateDescription(description.description) 3303 cl.UpdateDescription(description.description)
3272 return 0 3304 return 0
(...skipping 1552 matching lines...)
4825 if __name__ == '__main__': 4857 if __name__ == '__main__':
4826 # These affect sys.stdout so do it outside of main() to simplify mocks in 4858 # These affect sys.stdout so do it outside of main() to simplify mocks in
4827 # unit testing. 4859 # unit testing.
4828 fix_encoding.fix_encoding() 4860 fix_encoding.fix_encoding()
4829 setup_color.init() 4861 setup_color.init()
4830 try: 4862 try:
4831 sys.exit(main(sys.argv[1:])) 4863 sys.exit(main(sys.argv[1:]))
4832 except KeyboardInterrupt: 4864 except KeyboardInterrupt:
4833 sys.stderr.write('interrupted\n') 4865 sys.stderr.write('interrupted\n')
4834 sys.exit(1) 4866 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine