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

Side by Side Diff: git_cl.py

Issue 1935633002: Revert of git_cl: Add the ability to set the description. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 7 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 3261 matching lines...) Expand 10 before | Expand all | Expand 10 after
3272 with open(options.json_file, 'wb') as f: 3272 with open(options.json_file, 'wb') as f:
3273 json.dump(summary, f) 3273 json.dump(summary, f)
3274 return 0 3274 return 0
3275 3275
3276 3276
3277 @subcommand.usage('[codereview url or issue id]') 3277 @subcommand.usage('[codereview url or issue id]')
3278 def CMDdescription(parser, args): 3278 def CMDdescription(parser, args):
3279 """Brings up the editor for the current CL's description.""" 3279 """Brings up the editor for the current CL's description."""
3280 parser.add_option('-d', '--display', action='store_true', 3280 parser.add_option('-d', '--display', action='store_true',
3281 help='Display the description instead of opening an editor') 3281 help='Display the description instead of opening an editor')
3282 parser.add_option('-n', '--new-description',
3283 help='New description to set for this issue (- for stdin)')
3284 3282
3285 _add_codereview_select_options(parser) 3283 _add_codereview_select_options(parser)
3286 auth.add_auth_options(parser) 3284 auth.add_auth_options(parser)
3287 options, args = parser.parse_args(args) 3285 options, args = parser.parse_args(args)
3288 _process_codereview_select_options(parser, options) 3286 _process_codereview_select_options(parser, options)
3289 3287
3290 target_issue = None 3288 target_issue = None
3291 if len(args) > 0: 3289 if len(args) > 0:
3292 issue_arg = ParseIssueNumberArgument(args[0]) 3290 issue_arg = ParseIssueNumberArgument(args[0])
3293 if not issue_arg.valid: 3291 if not issue_arg.valid:
3294 parser.print_help() 3292 parser.print_help()
3295 return 1 3293 return 1
3296 target_issue = issue_arg.issue 3294 target_issue = issue_arg.issue
3297 3295
3298 auth_config = auth.extract_auth_config_from_options(options) 3296 auth_config = auth.extract_auth_config_from_options(options)
3299 3297
3300 cl = Changelist( 3298 cl = Changelist(
3301 auth_config=auth_config, issue=target_issue, 3299 auth_config=auth_config, issue=target_issue,
3302 codereview=options.forced_codereview) 3300 codereview=options.forced_codereview)
3303 3301
3304 if not cl.GetIssue(): 3302 if not cl.GetIssue():
3305 DieWithError('This branch has no associated changelist.') 3303 DieWithError('This branch has no associated changelist.')
3306 description = ChangeDescription(cl.GetDescription()) 3304 description = ChangeDescription(cl.GetDescription())
3307
3308 if options.display: 3305 if options.display:
3309 print description.description 3306 print description.description
3310 return 0 3307 return 0
3311 3308 description.prompt()
3312 if options.new_description:
3313 text = options.new_description
3314 if text == '-':
3315 text = '\n'.join(sys.stdin.splitlines())
3316
3317 description.set_description(text)
3318 else:
3319 description.prompt()
3320
3321 if cl.GetDescription() != description.description: 3309 if cl.GetDescription() != description.description:
3322 cl.UpdateDescription(description.description) 3310 cl.UpdateDescription(description.description)
3323 return 0 3311 return 0
3324 3312
3325 3313
3326 def CreateDescriptionFromLog(args): 3314 def CreateDescriptionFromLog(args):
3327 """Pulls out the commit log to use as a base for the CL description.""" 3315 """Pulls out the commit log to use as a base for the CL description."""
3328 log_args = [] 3316 log_args = []
3329 if len(args) == 1 and not args[0].endswith('.'): 3317 if len(args) == 1 and not args[0].endswith('.'):
3330 log_args = [args[0] + '..'] 3318 log_args = [args[0] + '..']
(...skipping 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after
4877 if __name__ == '__main__': 4865 if __name__ == '__main__':
4878 # These affect sys.stdout so do it outside of main() to simplify mocks in 4866 # These affect sys.stdout so do it outside of main() to simplify mocks in
4879 # unit testing. 4867 # unit testing.
4880 fix_encoding.fix_encoding() 4868 fix_encoding.fix_encoding()
4881 setup_color.init() 4869 setup_color.init()
4882 try: 4870 try:
4883 sys.exit(main(sys.argv[1:])) 4871 sys.exit(main(sys.argv[1:]))
4884 except KeyboardInterrupt: 4872 except KeyboardInterrupt:
4885 sys.stderr.write('interrupted\n') 4873 sys.stderr.write('interrupted\n')
4886 sys.exit(1) 4874 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