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

Side by Side Diff: git_cl/git_cl.py

Issue 6696010: Modify gcl to use suggested_reviewer output from presubmit_support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 9 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
« gcl.py ('K') | « gcl.py ('k') | tests/gcl_unittest.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/python 1 #!/usr/bin/python
2 # git-cl -- a git-command for integrating reviews on Rietveld 2 # git-cl -- a git-command for integrating reviews on Rietveld
3 # Copyright (C) 2008 Evan Martin <martine@danga.com> 3 # Copyright (C) 2008 Evan Martin <martine@danga.com>
4 4
5 import errno 5 import errno
6 import logging 6 import logging
7 import optparse 7 import optparse
8 import os 8 import os
9 import re 9 import re
10 import StringIO 10 import StringIO
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 751
752 output = presubmit_support.DoPresubmitChecks(change, committing, 752 output = presubmit_support.DoPresubmitChecks(change, committing,
753 verbose=False, output_stream=sys.stdout, input_stream=sys.stdin, 753 verbose=False, output_stream=sys.stdout, input_stream=sys.stdin,
754 default_presubmit=None, may_prompt=may_prompt, tbr=tbr, 754 default_presubmit=None, may_prompt=may_prompt, tbr=tbr,
755 host_url=cl.GetRietveldServer()) 755 host_url=cl.GetRietveldServer())
756 756
757 # TODO(dpranke): We should propagate the error out instead of calling exit(). 757 # TODO(dpranke): We should propagate the error out instead of calling exit().
758 if not output.should_continue(): 758 if not output.should_continue():
759 sys.exit(1) 759 sys.exit(1)
760 760
761 return output
762
761 763
762 def CMDpresubmit(parser, args): 764 def CMDpresubmit(parser, args):
763 """run presubmit tests on the current changelist""" 765 """run presubmit tests on the current changelist"""
764 parser.add_option('--upload', action='store_true', 766 parser.add_option('--upload', action='store_true',
765 help='Run upload hook instead of the push/dcommit hook') 767 help='Run upload hook instead of the push/dcommit hook')
766 (options, args) = parser.parse_args(args) 768 (options, args) = parser.parse_args(args)
767 769
768 # Make sure index is up-to-date before running diff-index. 770 # Make sure index is up-to-date before running diff-index.
769 RunGit(['update-index', '--refresh', '-q'], error_ok=True) 771 RunGit(['update-index', '--refresh', '-q'], error_ok=True)
770 if RunGit(['diff-index', 'HEAD']): 772 if RunGit(['diff-index', 'HEAD']):
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 return 1 825 return 1
824 826
825 cl = Changelist() 827 cl = Changelist()
826 if args: 828 if args:
827 base_branch = args[0] 829 base_branch = args[0]
828 else: 830 else:
829 # Default to diffing against the "upstream" branch. 831 # Default to diffing against the "upstream" branch.
830 base_branch = cl.GetUpstreamBranch() 832 base_branch = cl.GetUpstreamBranch()
831 args = [base_branch + "..."] 833 args = [base_branch + "..."]
832 834
833 if not options.bypass_hooks: 835 if not options.bypass_hooks and not options.force:
M-A Ruel 2011/03/15 19:11:57 What's the difference between --force and --bypass
chase 2011/03/15 20:48:58 IIRC, originally --bypass_hooks was to not run thi
834 hook_results = RunHook(committing=False, upstream_branch=base_branch, 836 hook_results = RunHook(committing=False, upstream_branch=base_branch,
835 rietveld_server=cl.GetRietveldServer(), tbr=False, 837 rietveld_server=cl.GetRietveldServer(), tbr=False,
836 may_prompt=(not options.force)) 838 may_prompt=True)
837 if not options.reviewers and hook_results.reviewers: 839 if not options.reviewers and hook_results.reviewers:
838 options.reviewers = hook_results.reviewers 840 options.reviewers = hook_results.reviewers
839 841
840 842
841 # --no-ext-diff is broken in some versions of Git, so try to work around 843 # --no-ext-diff is broken in some versions of Git, so try to work around
842 # this by overriding the environment (but there is still a problem if the 844 # this by overriding the environment (but there is still a problem if the
843 # git config key "diff.external" is used). 845 # git config key "diff.external" is used).
844 env = os.environ.copy() 846 env = os.environ.copy()
845 if 'GIT_EXTERNAL_DIFF' in env: 847 if 'GIT_EXTERNAL_DIFF' in env:
846 del env['GIT_EXTERNAL_DIFF'] 848 del env['GIT_EXTERNAL_DIFF']
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 svn_head = RunGit(['log', '--grep=^git-svn-id:', '-1', 976 svn_head = RunGit(['log', '--grep=^git-svn-id:', '-1',
975 '--pretty=format:%H']) 977 '--pretty=format:%H'])
976 extra_commits = RunGit(['rev-list', '^' + svn_head, base_branch]) 978 extra_commits = RunGit(['rev-list', '^' + svn_head, base_branch])
977 if extra_commits: 979 if extra_commits:
978 print ('This branch has %d additional commits not upstreamed yet.' 980 print ('This branch has %d additional commits not upstreamed yet.'
979 % len(extra_commits.splitlines())) 981 % len(extra_commits.splitlines()))
980 print ('Upstream "%s" or rebase this branch on top of the upstream trunk ' 982 print ('Upstream "%s" or rebase this branch on top of the upstream trunk '
981 'before attempting to %s.' % (base_branch, cmd)) 983 'before attempting to %s.' % (base_branch, cmd))
982 return 1 984 return 1
983 985
984 if not options.bypass_hooks: 986 if not options.bypass_hooks and not options.force:
985 RunHook(committing=True, upstream_branch=base_branch, 987 RunHook(committing=True, upstream_branch=base_branch,
986 rietveld_server=cl.GetRietveldServer(), tbr=options.tbr, 988 rietveld_server=cl.GetRietveldServer(), tbr=options.tbr,
987 may_prompt=(not options.force)) 989 may_prompt=True)
988 990
989 if not options.force and not options.bypass_hooks:
990 if cmd == 'dcommit': 991 if cmd == 'dcommit':
991 # Check the tree status if the tree status URL is set. 992 # Check the tree status if the tree status URL is set.
992 status = GetTreeStatus() 993 status = GetTreeStatus()
993 if 'closed' == status: 994 if 'closed' == status:
994 print ('The tree is closed. Please wait for it to reopen. Use ' 995 print ('The tree is closed. Please wait for it to reopen. Use '
995 '"git cl dcommit -f" to commit on a closed tree.') 996 '"git cl dcommit -f" to commit on a closed tree.')
996 return 1 997 return 1
997 elif 'unknown' == status: 998 elif 'unknown' == status:
998 print ('Unable to determine tree status. Please verify manually and ' 999 print ('Unable to determine tree status. Please verify manually and '
999 'use "git cl dcommit -f" to commit on a closed tree.') 1000 'use "git cl dcommit -f" to commit on a closed tree.')
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' 1367 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith '
1367 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 1368 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
1368 1369
1369 # Not a known command. Default to help. 1370 # Not a known command. Default to help.
1370 GenUsage(parser, 'help') 1371 GenUsage(parser, 'help')
1371 return CMDhelp(parser, argv) 1372 return CMDhelp(parser, argv)
1372 1373
1373 1374
1374 if __name__ == '__main__': 1375 if __name__ == '__main__':
1375 sys.exit(main(sys.argv[1:])) 1376 sys.exit(main(sys.argv[1:]))
OLDNEW
« gcl.py ('K') | « gcl.py ('k') | tests/gcl_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698