Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 2373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2384 # Extra options that can be specified at push time. Doc: | 2384 # Extra options that can be specified at push time. Doc: |
| 2385 # https://gerrit-review.googlesource.com/Documentation/user-upload.html | 2385 # https://gerrit-review.googlesource.com/Documentation/user-upload.html |
| 2386 refspec_opts = [] | 2386 refspec_opts = [] |
| 2387 if options.title: | 2387 if options.title: |
| 2388 # Per doc, spaces must be converted to underscores, and Gerrit will do the | 2388 # Per doc, spaces must be converted to underscores, and Gerrit will do the |
| 2389 # reverse on its side. | 2389 # reverse on its side. |
| 2390 if '_' in options.title: | 2390 if '_' in options.title: |
| 2391 print('WARNING: underscores in title will be converted to spaces.') | 2391 print('WARNING: underscores in title will be converted to spaces.') |
| 2392 refspec_opts.append('m=' + options.title.replace(' ', '_')) | 2392 refspec_opts.append('m=' + options.title.replace(' ', '_')) |
| 2393 | 2393 |
| 2394 receive_options = [] | |
| 2395 cc = self.GetCCList().split(',') | 2394 cc = self.GetCCList().split(',') |
|
Michael Achenbach
2016/04/13 12:43:04
Can there be spaces after the comma by any chance?
tandrii(chromium)
2016/04/13 12:53:14
good point, stripped.
| |
| 2396 if options.cc: | 2395 if options.cc: |
| 2397 cc.extend(options.cc) | 2396 cc.extend(options.cc) |
| 2398 cc = filter(None, cc) | 2397 cc = filter(None, cc) |
| 2399 if cc: | 2398 if cc: |
| 2400 receive_options += ['--cc=' + email for email in cc] | 2399 refspec_opts.extend('cc=' + email for email in cc) |
| 2400 | |
| 2401 if change_desc.get_reviewers(): | 2401 if change_desc.get_reviewers(): |
| 2402 receive_options.extend( | 2402 refspec_opts.extend('r=' + email for email in change_desc.get_reviewers()) |
| 2403 '--reviewer=' + email for email in change_desc.get_reviewers()) | |
| 2404 | 2403 |
| 2405 git_command = ['git', 'push'] | |
| 2406 if receive_options: | |
| 2407 # TODO(tandrii): clean this up in follow up. This doesn't work, as it gets | |
| 2408 # totally ignored by Gerrit. | |
| 2409 git_command.append('--receive-pack=git receive-pack %s' % | |
| 2410 ' '.join(receive_options)) | |
| 2411 | 2404 |
| 2412 refspec_suffix = '' | 2405 refspec_suffix = '' |
| 2413 if refspec_opts: | 2406 if refspec_opts: |
| 2414 refspec_suffix = '%' + ','.join(refspec_opts) | 2407 refspec_suffix = '%' + ','.join(refspec_opts) |
| 2415 assert ' ' not in refspec_suffix, ( | 2408 assert ' ' not in refspec_suffix, ( |
| 2416 'spaces not allowed in refspec: "%s"' % refspec_suffix) | 2409 'spaces not allowed in refspec: "%s"' % refspec_suffix) |
| 2417 | |
| 2418 refspec = '%s:refs/for/%s%s' % (ref_to_push, branch, refspec_suffix) | 2410 refspec = '%s:refs/for/%s%s' % (ref_to_push, branch, refspec_suffix) |
| 2419 git_command += [gerrit_remote, refspec] | |
| 2420 | 2411 |
| 2421 push_stdout = gclient_utils.CheckCallAndFilter( | 2412 push_stdout = gclient_utils.CheckCallAndFilter( |
| 2422 git_command, | 2413 ['git', 'push', gerrit_remote, refspec], |
| 2423 print_stdout=True, | 2414 print_stdout=True, |
| 2424 # Flush after every line: useful for seeing progress when running as | 2415 # Flush after every line: useful for seeing progress when running as |
| 2425 # recipe. | 2416 # recipe. |
| 2426 filter_fn=lambda _: sys.stdout.flush()) | 2417 filter_fn=lambda _: sys.stdout.flush()) |
| 2427 | 2418 |
| 2428 if options.squash: | 2419 if options.squash: |
| 2429 regex = re.compile(r'remote:\s+https?://[\w\-\.\/]*/(\d+)\s.*') | 2420 regex = re.compile(r'remote:\s+https?://[\w\-\.\/]*/(\d+)\s.*') |
| 2430 change_numbers = [m.group(1) | 2421 change_numbers = [m.group(1) |
| 2431 for m in map(regex.match, push_stdout.splitlines()) | 2422 for m in map(regex.match, push_stdout.splitlines()) |
| 2432 if m] | 2423 if m] |
| (...skipping 2280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4713 if __name__ == '__main__': | 4704 if __name__ == '__main__': |
| 4714 # These affect sys.stdout so do it outside of main() to simplify mocks in | 4705 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 4715 # unit testing. | 4706 # unit testing. |
| 4716 fix_encoding.fix_encoding() | 4707 fix_encoding.fix_encoding() |
| 4717 setup_color.init() | 4708 setup_color.init() |
| 4718 try: | 4709 try: |
| 4719 sys.exit(main(sys.argv[1:])) | 4710 sys.exit(main(sys.argv[1:])) |
| 4720 except KeyboardInterrupt: | 4711 except KeyboardInterrupt: |
| 4721 sys.stderr.write('interrupted\n') | 4712 sys.stderr.write('interrupted\n') |
| 4722 sys.exit(1) | 4713 sys.exit(1) |
| OLD | NEW |