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 2321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2332 if reply.lower().startswith('y'): | 2332 if reply.lower().startswith('y'): |
2333 gclient_utils.rm_file_or_tree(hook) | 2333 gclient_utils.rm_file_or_tree(hook) |
2334 print('Gerrit commit-msg hook removed.') | 2334 print('Gerrit commit-msg hook removed.') |
2335 else: | 2335 else: |
2336 print('OK, will keep Gerrit commit-msg hook in place.') | 2336 print('OK, will keep Gerrit commit-msg hook in place.') |
2337 | 2337 |
2338 def CMDUploadChange(self, options, args, change): | 2338 def CMDUploadChange(self, options, args, change): |
2339 """Upload the current branch to Gerrit.""" | 2339 """Upload the current branch to Gerrit.""" |
2340 if options.squash and options.no_squash: | 2340 if options.squash and options.no_squash: |
2341 DieWithError('Can only use one of --squash or --no-squash') | 2341 DieWithError('Can only use one of --squash or --no-squash') |
2342 # TODO(tandrii): remove this by June 20. | |
2343 if (RunGit(['config', '--bool', 'gerrit.squash-uploads'], | |
2344 error_ok=True).strip() != 'false' and not options.squash and | |
2345 not options.no_squash): | |
2346 print('\n\nHi! You are using git cl upload in --no-squash mode.\n' | |
2347 'Chrome infrastructure wants to make --squash the default.\n' | |
2348 'To ensure that --no-squash is still the default for YOU do:\n' | |
2349 ' git config --bool gerrit.squash-uploads false\n' | |
2350 'See https://goo.gl/dnK2gV (use chromium.org account!) and ' | |
2351 'let us know what you think. Thanks!\n' | |
2352 'BUG: http://crbug.com/611892\n\n') | |
2353 | |
2342 options.squash = ((settings.GetSquashGerritUploads() or options.squash) and | 2354 options.squash = ((settings.GetSquashGerritUploads() or options.squash) and |
tandrii(chromium)
2016/06/10 15:33:03
this is the other point at which it's called.
Yes,
| |
2343 not options.no_squash) | 2355 not options.no_squash) |
2356 | |
2344 # We assume the remote called "origin" is the one we want. | 2357 # We assume the remote called "origin" is the one we want. |
2345 # It is probably not worthwhile to support different workflows. | 2358 # It is probably not worthwhile to support different workflows. |
2346 gerrit_remote = 'origin' | 2359 gerrit_remote = 'origin' |
2347 | 2360 |
2348 remote, remote_branch = self.GetRemoteBranch() | 2361 remote, remote_branch = self.GetRemoteBranch() |
2349 branch = GetTargetRef(remote, remote_branch, options.target_branch, | 2362 branch = GetTargetRef(remote, remote_branch, options.target_branch, |
2350 pending_prefix='') | 2363 pending_prefix='') |
2351 | 2364 |
2352 if options.squash: | 2365 if options.squash: |
2353 self._GerritCommitMsgHookCheck(offer_removal=not options.force) | 2366 self._GerritCommitMsgHookCheck(offer_removal=not options.force) |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2863 """ | 2876 """ |
2864 if not settings.GetIsGerrit(): | 2877 if not settings.GetIsGerrit(): |
2865 return | 2878 return |
2866 src = 'https://gerrit-review.googlesource.com/tools/hooks/commit-msg' | 2879 src = 'https://gerrit-review.googlesource.com/tools/hooks/commit-msg' |
2867 dst = os.path.join(settings.GetRoot(), '.git', 'hooks', 'commit-msg') | 2880 dst = os.path.join(settings.GetRoot(), '.git', 'hooks', 'commit-msg') |
2868 if not os.access(dst, os.X_OK): | 2881 if not os.access(dst, os.X_OK): |
2869 if os.path.exists(dst): | 2882 if os.path.exists(dst): |
2870 if not force: | 2883 if not force: |
2871 return | 2884 return |
2872 try: | 2885 try: |
2873 print( | |
2874 'WARNING: installing Gerrit commit-msg hook.\n' | |
2875 ' This behavior of git cl will soon be disabled.\n' | |
2876 ' See bug http://crbug.com/579176.') | |
2877 urlretrieve(src, dst) | 2886 urlretrieve(src, dst) |
2878 if not hasSheBang(dst): | 2887 if not hasSheBang(dst): |
2879 DieWithError('Not a script: %s\n' | 2888 DieWithError('Not a script: %s\n' |
2880 'You need to download from\n%s\n' | 2889 'You need to download from\n%s\n' |
2881 'into .git/hooks/commit-msg and ' | 2890 'into .git/hooks/commit-msg and ' |
2882 'chmod +x .git/hooks/commit-msg' % (dst, src)) | 2891 'chmod +x .git/hooks/commit-msg' % (dst, src)) |
2883 os.chmod(dst, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) | 2892 os.chmod(dst, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) |
2884 except Exception: | 2893 except Exception: |
2885 if os.path.exists(dst): | 2894 if os.path.exists(dst): |
2886 os.remove(dst) | 2895 os.remove(dst) |
(...skipping 2137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5024 if __name__ == '__main__': | 5033 if __name__ == '__main__': |
5025 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5034 # These affect sys.stdout so do it outside of main() to simplify mocks in |
5026 # unit testing. | 5035 # unit testing. |
5027 fix_encoding.fix_encoding() | 5036 fix_encoding.fix_encoding() |
5028 setup_color.init() | 5037 setup_color.init() |
5029 try: | 5038 try: |
5030 sys.exit(main(sys.argv[1:])) | 5039 sys.exit(main(sys.argv[1:])) |
5031 except KeyboardInterrupt: | 5040 except KeyboardInterrupt: |
5032 sys.stderr.write('interrupted\n') | 5041 sys.stderr.write('interrupted\n') |
5033 sys.exit(1) | 5042 sys.exit(1) |
OLD | NEW |