OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 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 import optparse |
6 import os | 7 import os |
7 import sys | 8 import sys |
8 from subprocess import Popen, PIPE | 9 from subprocess import Popen, PIPE |
9 | 10 |
10 # Try locating depot_tools from the user's PATH. | 11 # Try locating depot_tools from the user's PATH. |
11 depot_tools_path = None | 12 depot_tools_path = None |
12 | 13 |
13 # First parse PATH if there's a "depot_tools" inside | 14 # First parse PATH if there's a "depot_tools" inside |
14 for path in os.environ.get("PATH").split(os.pathsep): | 15 for path in os.environ.get("PATH").split(os.pathsep): |
15 if not path.endswith("depot_tools") and not path.endswith("depot_tools/"): | 16 if not path.endswith("depot_tools") and not path.endswith("depot_tools/"): |
(...skipping 19 matching lines...) Expand all Loading... |
35 sys.exit(1) | 36 sys.exit(1) |
36 | 37 |
37 # Try importing git_cl_hooks from depot_tools. | 38 # Try importing git_cl_hooks from depot_tools. |
38 try: | 39 try: |
39 import git_cl_hooks | 40 import git_cl_hooks |
40 except ImportError: | 41 except ImportError: |
41 print "ERROR: Could not import git_cl_hooks from depot_tools in your PATH." | 42 print "ERROR: Could not import git_cl_hooks from depot_tools in your PATH." |
42 print "ERROR: Make sure %s is up-to-date and try again." % depot_tools_path | 43 print "ERROR: Make sure %s is up-to-date and try again." % depot_tools_path |
43 sys.exit(1) | 44 sys.exit(1) |
44 | 45 |
45 # Ensure we were called with the necessary number of arguments. | 46 parser = optparse.OptionParser() |
46 program_name = os.path.basename(sys.argv[0]) | 47 parser.set_usage('%prog [options] <upstream-branch>') |
47 if len(sys.argv) != 2: | 48 parser.add_option('--tbr', action='store_true', default=False, |
48 print "usage: %s [upstream branch]" % program_name | 49 help='skip checks for reviewers, owners') |
49 sys.exit(1) | 50 parser.add_option('--host-url', default=None, |
| 51 help='scheme, origin, and port for Rietveld server') |
| 52 options, args = parser.parse_args() |
| 53 if len(args) != 1: |
| 54 parser.print_help() |
| 55 sys.exit(1) |
50 | 56 |
51 # Run the hooks library with our arguments. | 57 # Run the hooks library with our arguments. |
52 exec git_cl_hooks.RunHooks(hook_name=program_name, upstream_branch=sys.argv[1]) | 58 exec git_cl_hooks.RunHooks(hook_name=parser.get_prog_name(), |
| 59 upstream_branch=args[0], |
| 60 cmd_line_options=options) |
OLD | NEW |