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

Side by Side Diff: git_cl.py

Issue 10384150: When converting -m/--message to -t, make sure to handle the case --message=foo (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: Address review comments Created 8 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 | Annotate | Revision Log
« no previous file with comments | « gcl.py ('k') | 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.""" 8 """A git-command for integrating reviews on Rietveld."""
9 9
10 import json 10 import json
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 def RietveldUpload(options, args, cl): 959 def RietveldUpload(options, args, cl):
960 """upload the patch to rietveld.""" 960 """upload the patch to rietveld."""
961 upload_args = ['--assume_yes'] # Don't ask about untracked files. 961 upload_args = ['--assume_yes'] # Don't ask about untracked files.
962 upload_args.extend(['--server', cl.GetRietveldServer()]) 962 upload_args.extend(['--server', cl.GetRietveldServer()])
963 if options.emulate_svn_auto_props: 963 if options.emulate_svn_auto_props:
964 upload_args.append('--emulate_svn_auto_props') 964 upload_args.append('--emulate_svn_auto_props')
965 965
966 change_desc = None 966 change_desc = None
967 967
968 if cl.GetIssue(): 968 if cl.GetIssue():
969 if options.message: 969 if options.title:
970 upload_args.extend(['--message', options.message]) 970 upload_args.extend(['--title', options.title])
971 elif options.message:
972 # TODO(rogerta): for now, the -m option will also set the --title option
973 # for upload.py. Soon this will be changed to set the --message option.
974 # Will wait until people are used to typing -t instead of -m.
975 upload_args.extend(['--title', options.message])
971 upload_args.extend(['--issue', cl.GetIssue()]) 976 upload_args.extend(['--issue', cl.GetIssue()])
972 print ("This branch is associated with issue %s. " 977 print ("This branch is associated with issue %s. "
973 "Adding patch to that issue." % cl.GetIssue()) 978 "Adding patch to that issue." % cl.GetIssue())
974 else: 979 else:
980 if options.title:
981 upload_args.extend(['--title', options.title])
975 message = options.message or CreateDescriptionFromLog(args) 982 message = options.message or CreateDescriptionFromLog(args)
976 change_desc = ChangeDescription(message, options.reviewers) 983 change_desc = ChangeDescription(message, options.reviewers)
977 if not options.force: 984 if not options.force:
978 change_desc.Prompt() 985 change_desc.Prompt()
979 change_desc.ParseDescription() 986 change_desc.ParseDescription()
980 987
981 if change_desc.IsEmpty(): 988 if change_desc.IsEmpty():
982 print "Description is empty; aborting." 989 print "Description is empty; aborting."
983 return 1 990 return 1
984 991
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 return 0 1043 return 0
1037 1044
1038 1045
1039 @usage('[args to "git diff"]') 1046 @usage('[args to "git diff"]')
1040 def CMDupload(parser, args): 1047 def CMDupload(parser, args):
1041 """upload the current changelist to codereview""" 1048 """upload the current changelist to codereview"""
1042 parser.add_option('--bypass-hooks', action='store_true', dest='bypass_hooks', 1049 parser.add_option('--bypass-hooks', action='store_true', dest='bypass_hooks',
1043 help='bypass upload presubmit hook') 1050 help='bypass upload presubmit hook')
1044 parser.add_option('-f', action='store_true', dest='force', 1051 parser.add_option('-f', action='store_true', dest='force',
1045 help="force yes to questions (don't prompt)") 1052 help="force yes to questions (don't prompt)")
1046 parser.add_option('-m', dest='message', help='message for patch') 1053 parser.add_option('-m', dest='message', help='message for patchset')
1054 parser.add_option('-t', dest='title', help='title for patchset')
1047 parser.add_option('-r', '--reviewers', 1055 parser.add_option('-r', '--reviewers',
1048 help='reviewer email addresses') 1056 help='reviewer email addresses')
1049 parser.add_option('--cc', 1057 parser.add_option('--cc',
1050 help='cc email addresses') 1058 help='cc email addresses')
1051 parser.add_option('--send-mail', action='store_true', 1059 parser.add_option('--send-mail', action='store_true',
1052 help='send email to reviewer immediately') 1060 help='send email to reviewer immediately')
1053 parser.add_option("--emulate_svn_auto_props", action="store_true", 1061 parser.add_option("--emulate_svn_auto_props", action="store_true",
1054 dest="emulate_svn_auto_props", 1062 dest="emulate_svn_auto_props",
1055 help="Emulate Subversion's auto properties feature.") 1063 help="Emulate Subversion's auto properties feature.")
1056 parser.add_option("--desc_from_logs", action="store_true", 1064 parser.add_option("--desc_from_logs", action="store_true",
1057 dest="from_logs", 1065 dest="from_logs",
1058 help="""Squashes git commit logs into change description and 1066 help="""Squashes git commit logs into change description and
1059 uses message as subject""") 1067 uses message as subject""")
1060 parser.add_option('-c', '--use-commit-queue', action='store_true', 1068 parser.add_option('-c', '--use-commit-queue', action='store_true',
1061 help='tell the commit queue to commit this patchset') 1069 help='tell the commit queue to commit this patchset')
1062 if settings.GetIsGerrit(): 1070 if settings.GetIsGerrit():
1063 parser.add_option('--target_branch', dest='target_branch', default='master', 1071 parser.add_option('--target_branch', dest='target_branch', default='master',
1064 help='target branch to upload') 1072 help='target branch to upload')
1065 (options, args) = parser.parse_args(args) 1073 (options, args) = parser.parse_args(args)
1066 1074
1075 # Print warning if the user used the -m/--message argument. This will soon
1076 # change to -t/--title.
1077 if options.message:
1078 print >> sys.stderr, (
1079 '\nWARNING: Use -t or --title to set the title of the patchset.\n'
1080 'In the near future, -m or --message will send a message instead.\n'
1081 'See http://goo.gl/JGg0Z for details.\n')
1082
1067 # Make sure index is up-to-date before running diff-index. 1083 # Make sure index is up-to-date before running diff-index.
1068 RunGit(['update-index', '--refresh', '-q'], error_ok=True) 1084 RunGit(['update-index', '--refresh', '-q'], error_ok=True)
1069 if RunGit(['diff-index', 'HEAD']): 1085 if RunGit(['diff-index', 'HEAD']):
1070 print 'Cannot upload with a dirty tree. You must commit locally first.' 1086 print 'Cannot upload with a dirty tree. You must commit locally first.'
1071 return 1 1087 return 1
1072 1088
1073 cl = Changelist() 1089 cl = Changelist()
1074 if args: 1090 if args:
1075 # TODO(ukai): is it ok for gerrit case? 1091 # TODO(ukai): is it ok for gerrit case?
1076 base_branch = args[0] 1092 base_branch = args[0]
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 1551 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
1536 1552
1537 # Not a known command. Default to help. 1553 # Not a known command. Default to help.
1538 GenUsage(parser, 'help') 1554 GenUsage(parser, 'help')
1539 return CMDhelp(parser, argv) 1555 return CMDhelp(parser, argv)
1540 1556
1541 1557
1542 if __name__ == '__main__': 1558 if __name__ == '__main__':
1543 fix_encoding.fix_encoding() 1559 fix_encoding.fix_encoding()
1544 sys.exit(main(sys.argv[1:])) 1560 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « gcl.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698