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

Side by Side Diff: git_cl.py

Issue 1922133006: 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') | 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 3251 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 @subcommand.usage('[codereview url or issue id]')
3268 def CMDdescription(parser, args): 3268 def CMDdescription(parser, args):
3269 """Brings up the editor for the current CL's description.""" 3269 """Brings up the editor for the current CL's description."""
3270 parser.add_option('-d', '--display', action='store_true', 3270 parser.add_option('-d', '--display', action='store_true',
3271 help='Display the description instead of opening an editor') 3271 help='Display the description instead of opening an editor')
3272 parser.add_option('-n', '--new-description',
3273 help='New description to set for this issue (- for stdin)')
3272 3274
3273 _add_codereview_select_options(parser) 3275 _add_codereview_select_options(parser)
3274 auth.add_auth_options(parser) 3276 auth.add_auth_options(parser)
3275 options, args = parser.parse_args(args) 3277 options, args = parser.parse_args(args)
3276 _process_codereview_select_options(parser, options) 3278 _process_codereview_select_options(parser, options)
3277 3279
3278 target_issue = None 3280 target_issue = None
3279 if len(args) > 0: 3281 if len(args) > 0:
3280 issue_arg = ParseIssueNumberArgument(args[0]) 3282 issue_arg = ParseIssueNumberArgument(args[0])
3281 if not issue_arg.valid: 3283 if not issue_arg.valid:
3282 parser.print_help() 3284 parser.print_help()
3283 return 1 3285 return 1
3284 target_issue = issue_arg.issue 3286 target_issue = issue_arg.issue
3285 3287
3286 auth_config = auth.extract_auth_config_from_options(options) 3288 auth_config = auth.extract_auth_config_from_options(options)
3287 3289
3288 cl = Changelist( 3290 cl = Changelist(
3289 auth_config=auth_config, issue=target_issue, 3291 auth_config=auth_config, issue=target_issue,
3290 codereview=options.forced_codereview) 3292 codereview=options.forced_codereview)
3291 3293
3292 if not cl.GetIssue(): 3294 if not cl.GetIssue():
3293 DieWithError('This branch has no associated changelist.') 3295 DieWithError('This branch has no associated changelist.')
3294 description = ChangeDescription(cl.GetDescription()) 3296 description = ChangeDescription(cl.GetDescription())
3297
3295 if options.display: 3298 if options.display:
3296 print description.description 3299 print description.description
3297 return 0 3300 return 0
3298 description.prompt() 3301
3302 if options.new_description:
3303 text = options.new_description
3304 if text == '-':
3305 text = ''
3306 for line in sys.stdin:
3307 text += line + '\n'
tandrii(chromium) 2016/04/28 05:13:56 one liner instead of three is faster: text = '\n'
martiniss 2016/04/28 20:51:38 Fixed. I had to make another mock in the tests, so
3308
3309 description.set_description(text)
3310 else:
3311 description.prompt()
3312
3299 if cl.GetDescription() != description.description: 3313 if cl.GetDescription() != description.description:
3300 cl.UpdateDescription(description.description) 3314 cl.UpdateDescription(description.description)
3301 return 0 3315 return 0
3302 3316
3303 3317
3304 def CreateDescriptionFromLog(args): 3318 def CreateDescriptionFromLog(args):
3305 """Pulls out the commit log to use as a base for the CL description.""" 3319 """Pulls out the commit log to use as a base for the CL description."""
3306 log_args = [] 3320 log_args = []
3307 if len(args) == 1 and not args[0].endswith('.'): 3321 if len(args) == 1 and not args[0].endswith('.'):
3308 log_args = [args[0] + '..'] 3322 log_args = [args[0] + '..']
(...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after
4854 if __name__ == '__main__': 4868 if __name__ == '__main__':
4855 # These affect sys.stdout so do it outside of main() to simplify mocks in 4869 # These affect sys.stdout so do it outside of main() to simplify mocks in
4856 # unit testing. 4870 # unit testing.
4857 fix_encoding.fix_encoding() 4871 fix_encoding.fix_encoding()
4858 setup_color.init() 4872 setup_color.init()
4859 try: 4873 try:
4860 sys.exit(main(sys.argv[1:])) 4874 sys.exit(main(sys.argv[1:]))
4861 except KeyboardInterrupt: 4875 except KeyboardInterrupt:
4862 sys.stderr.write('interrupted\n') 4876 sys.stderr.write('interrupted\n')
4863 sys.exit(1) 4877 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