| OLD | NEW |
| 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 subprocess | 10 import subprocess |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 print 'Cannot presubmit with a dirty tree. You must commit locally first.' | 833 print 'Cannot presubmit with a dirty tree. You must commit locally first.' |
| 834 return 1 | 834 return 1 |
| 835 | 835 |
| 836 cl = Changelist() | 836 cl = Changelist() |
| 837 if args: | 837 if args: |
| 838 base_branch = args[0] | 838 base_branch = args[0] |
| 839 else: | 839 else: |
| 840 # Default to diffing against the "upstream" branch. | 840 # Default to diffing against the "upstream" branch. |
| 841 base_branch = cl.GetUpstreamBranch() | 841 base_branch = cl.GetUpstreamBranch() |
| 842 | 842 |
| 843 if options.upload: | 843 RunHook(committing=not options.upload, upstream_branch=base_branch, |
| 844 print '*** Presubmit checks for UPLOAD would report: ***' | 844 rietveld_server=cl.GetRietveldServer(), tbr=False, |
| 845 RunHook(committing=False, upstream_branch=base_branch, | 845 may_prompt=False) |
| 846 rietveld_server=cl.GetRietveldServer(), tbr=False, | 846 return 0 |
| 847 may_prompt=False) | |
| 848 return 0 | |
| 849 else: | |
| 850 print '*** Presubmit checks for DCOMMIT would report: ***' | |
| 851 RunHook(committing=True, upstream_branch=base_branch, | |
| 852 rietveld_server=cl.GetRietveldServer, tbr=False, | |
| 853 may_prompt=False) | |
| 854 return 0 | |
| 855 | 847 |
| 856 | 848 |
| 857 @usage('[args to "git diff"]') | 849 @usage('[args to "git diff"]') |
| 858 def CMDupload(parser, args): | 850 def CMDupload(parser, args): |
| 859 """upload the current changelist to codereview""" | 851 """upload the current changelist to codereview""" |
| 860 parser.add_option('--bypass-hooks', action='store_true', dest='bypass_hooks', | 852 parser.add_option('--bypass-hooks', action='store_true', dest='bypass_hooks', |
| 861 help='bypass upload presubmit hook') | 853 help='bypass upload presubmit hook') |
| 862 parser.add_option('-f', action='store_true', dest='force', | 854 parser.add_option('-f', action='store_true', dest='force', |
| 863 help="force yes to questions (don't prompt)") | 855 help="force yes to questions (don't prompt)") |
| 864 parser.add_option('-m', dest='message', help='message for patch') | 856 parser.add_option('-m', dest='message', help='message for patch') |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1423 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 1415 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 1424 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1416 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 1425 | 1417 |
| 1426 # Not a known command. Default to help. | 1418 # Not a known command. Default to help. |
| 1427 GenUsage(parser, 'help') | 1419 GenUsage(parser, 'help') |
| 1428 return CMDhelp(parser, argv) | 1420 return CMDhelp(parser, argv) |
| 1429 | 1421 |
| 1430 | 1422 |
| 1431 if __name__ == '__main__': | 1423 if __name__ == '__main__': |
| 1432 sys.exit(main(sys.argv[1:])) | 1424 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |