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

Side by Side Diff: git_cl.py

Issue 2007873002: Gerrit git cl upload: obey -s --send-mail option. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: shorter 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 2450 matching lines...) Expand 10 before | Expand all | Expand 10 after
2461 # Extra options that can be specified at push time. Doc: 2461 # Extra options that can be specified at push time. Doc:
2462 # https://gerrit-review.googlesource.com/Documentation/user-upload.html 2462 # https://gerrit-review.googlesource.com/Documentation/user-upload.html
2463 refspec_opts = [] 2463 refspec_opts = []
2464 if options.title: 2464 if options.title:
2465 # Per doc, spaces must be converted to underscores, and Gerrit will do the 2465 # Per doc, spaces must be converted to underscores, and Gerrit will do the
2466 # reverse on its side. 2466 # reverse on its side.
2467 if '_' in options.title: 2467 if '_' in options.title:
2468 print('WARNING: underscores in title will be converted to spaces.') 2468 print('WARNING: underscores in title will be converted to spaces.')
2469 refspec_opts.append('m=' + options.title.replace(' ', '_')) 2469 refspec_opts.append('m=' + options.title.replace(' ', '_'))
2470 2470
2471 if options.send_mail:
2472 if not change_desc.get_reviewers():
2473 DieWithError('Must specify reviewers to send email.')
2474 refspec_opts.append('notify=ALL')
2475 else:
2476 refspec_opts.append('notify=NONE')
2477
2471 cc = self.GetCCList().split(',') 2478 cc = self.GetCCList().split(',')
2472 if options.cc: 2479 if options.cc:
2473 cc.extend(options.cc) 2480 cc.extend(options.cc)
2474 cc = filter(None, cc) 2481 cc = filter(None, cc)
2475 if cc: 2482 if cc:
2476 # refspec_opts.extend('cc=' + email.strip() for email in cc) 2483 # refspec_opts.extend('cc=' + email.strip() for email in cc)
2477 # TODO(tandrii): enable this back. http://crbug.com/604377 2484 # TODO(tandrii): enable this back. http://crbug.com/604377
2478 print('WARNING: Gerrit doesn\'t yet support cc-ing arbitrary emails.\n' 2485 print('WARNING: Gerrit doesn\'t yet support cc-ing arbitrary emails.\n'
2479 ' Ignoring cc-ed emails. See http://crbug.com/604377.') 2486 ' Ignoring cc-ed emails. See http://crbug.com/604377.')
2480 2487
2481 if change_desc.get_reviewers(): 2488 if change_desc.get_reviewers():
2482 refspec_opts.extend('r=' + email.strip() 2489 refspec_opts.extend('r=' + email.strip()
2483 for email in change_desc.get_reviewers()) 2490 for email in change_desc.get_reviewers())
2484 2491
2485
2486 refspec_suffix = '' 2492 refspec_suffix = ''
2487 if refspec_opts: 2493 if refspec_opts:
2488 refspec_suffix = '%' + ','.join(refspec_opts) 2494 refspec_suffix = '%' + ','.join(refspec_opts)
2489 assert ' ' not in refspec_suffix, ( 2495 assert ' ' not in refspec_suffix, (
2490 'spaces not allowed in refspec: "%s"' % refspec_suffix) 2496 'spaces not allowed in refspec: "%s"' % refspec_suffix)
2491 refspec = '%s:refs/for/%s%s' % (ref_to_push, branch, refspec_suffix) 2497 refspec = '%s:refs/for/%s%s' % (ref_to_push, branch, refspec_suffix)
2492 2498
2493 push_stdout = gclient_utils.CheckCallAndFilter( 2499 push_stdout = gclient_utils.CheckCallAndFilter(
2494 ['git', 'push', gerrit_remote, refspec], 2500 ['git', 'push', gerrit_remote, refspec],
2495 print_stdout=True, 2501 print_stdout=True,
(...skipping 2405 matching lines...) Expand 10 before | Expand all | Expand 10 after
4901 if __name__ == '__main__': 4907 if __name__ == '__main__':
4902 # These affect sys.stdout so do it outside of main() to simplify mocks in 4908 # These affect sys.stdout so do it outside of main() to simplify mocks in
4903 # unit testing. 4909 # unit testing.
4904 fix_encoding.fix_encoding() 4910 fix_encoding.fix_encoding()
4905 setup_color.init() 4911 setup_color.init()
4906 try: 4912 try:
4907 sys.exit(main(sys.argv[1:])) 4913 sys.exit(main(sys.argv[1:]))
4908 except KeyboardInterrupt: 4914 except KeyboardInterrupt:
4909 sys.stderr.write('interrupted\n') 4915 sys.stderr.write('interrupted\n')
4910 sys.exit(1) 4916 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