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

Side by Side Diff: git_cl.py

Issue 8735018: Make --send-mail more useful by not requiring -r (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years 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 | « 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) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 logging 10 import logging
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 env = os.environ.copy() 913 env = os.environ.copy()
914 if 'GIT_EXTERNAL_DIFF' in env: 914 if 'GIT_EXTERNAL_DIFF' in env:
915 del env['GIT_EXTERNAL_DIFF'] 915 del env['GIT_EXTERNAL_DIFF']
916 subprocess2.call( 916 subprocess2.call(
917 ['git', 'diff', '--no-ext-diff', '--stat', '-M'] + args, env=env) 917 ['git', 'diff', '--no-ext-diff', '--stat', '-M'] + args, env=env)
918 918
919 upload_args = ['--assume_yes'] # Don't ask about untracked files. 919 upload_args = ['--assume_yes'] # Don't ask about untracked files.
920 upload_args.extend(['--server', cl.GetRietveldServer()]) 920 upload_args.extend(['--server', cl.GetRietveldServer()])
921 if options.emulate_svn_auto_props: 921 if options.emulate_svn_auto_props:
922 upload_args.append('--emulate_svn_auto_props') 922 upload_args.append('--emulate_svn_auto_props')
923 if options.send_mail:
924 if not options.reviewers:
925 DieWithError("Must specify reviewers to send email.")
926 upload_args.append('--send_mail')
927 if options.from_logs and not options.message: 923 if options.from_logs and not options.message:
928 print 'Must set message for subject line if using desc_from_logs' 924 print 'Must set message for subject line if using desc_from_logs'
929 return 1 925 return 1
930 926
931 change_desc = None 927 change_desc = None
932 928
933 if cl.GetIssue(): 929 if cl.GetIssue():
934 if options.message: 930 if options.message:
935 upload_args.extend(['--message', options.message]) 931 upload_args.extend(['--message', options.message])
936 upload_args.extend(['--issue', cl.GetIssue()]) 932 upload_args.extend(['--issue', cl.GetIssue()])
937 print ("This branch is associated with issue %s. " 933 print ("This branch is associated with issue %s. "
938 "Adding patch to that issue." % cl.GetIssue()) 934 "Adding patch to that issue." % cl.GetIssue())
939 else: 935 else:
940 log_desc = CreateDescriptionFromLog(args) 936 log_desc = CreateDescriptionFromLog(args)
941 change_desc = ChangeDescription(options.message, log_desc, 937 change_desc = ChangeDescription(options.message, log_desc,
942 options.reviewers) 938 options.reviewers)
943 if not options.from_logs: 939 if not options.from_logs:
944 change_desc.Update() 940 change_desc.Update()
945 941
946 if change_desc.IsEmpty(): 942 if change_desc.IsEmpty():
947 print "Description is empty; aborting." 943 print "Description is empty; aborting."
948 return 1 944 return 1
949 945
950 upload_args.extend(['--message', change_desc.subject]) 946 upload_args.extend(['--message', change_desc.subject])
951 upload_args.extend(['--description', change_desc.description]) 947 upload_args.extend(['--description', change_desc.description])
952 if change_desc.reviewers: 948 if change_desc.reviewers:
953 upload_args.extend(['--reviewers', change_desc.reviewers]) 949 upload_args.extend(['--reviewers', change_desc.reviewers])
950 if options.send_mail:
951 if not change_desc.reviewers:
952 DieWithError("Must specify reviewers to send email.")
953 upload_args.append('--send_mail')
954 cc = ','.join(filter(None, (cl.GetCCList(), options.cc))) 954 cc = ','.join(filter(None, (cl.GetCCList(), options.cc)))
955 if cc: 955 if cc:
956 upload_args.extend(['--cc', cc]) 956 upload_args.extend(['--cc', cc])
957 957
958 # Include the upstream repo's URL in the change -- this is useful for 958 # Include the upstream repo's URL in the change -- this is useful for
959 # projects that have their source spread across multiple repos. 959 # projects that have their source spread across multiple repos.
960 remote_url = None 960 remote_url = None
961 if settings.GetIsGitSvn(): 961 if settings.GetIsGitSvn():
962 # URL is dependent on the current directory. 962 # URL is dependent on the current directory.
963 data = RunGit(['svn', 'info'], cwd=settings.GetRoot()) 963 data = RunGit(['svn', 'info'], cwd=settings.GetRoot())
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 1412 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
1413 1413
1414 # Not a known command. Default to help. 1414 # Not a known command. Default to help.
1415 GenUsage(parser, 'help') 1415 GenUsage(parser, 'help')
1416 return CMDhelp(parser, argv) 1416 return CMDhelp(parser, argv)
1417 1417
1418 1418
1419 if __name__ == '__main__': 1419 if __name__ == '__main__':
1420 fix_encoding.fix_encoding() 1420 fix_encoding.fix_encoding()
1421 sys.exit(main(sys.argv[1:])) 1421 sys.exit(main(sys.argv[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