You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
depot_tools/git-cl-upload-hook

41 lines
1.2 KiB
Python

#!/usr/bin/python
# Copyright (c) 2009 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import sys
# Try locating depot_tools from the user's PATH.
depot_tools_path = None
for path in os.environ.get("PATH").split(os.pathsep):
if not path.endswith("depot_tools"):
continue
depot_tools_path = path
break
# If we found depot_tools, add it to the script's import path.
if depot_tools_path:
sys.path.append(depot_tools_path)
else:
print "ERROR: Could not find depot_tools in your PATH."
print "ERROR: Please add it to your PATH and try again."
sys.exit(1)
# Try importing git_cl_hooks from depot_tools.
try:
import git_cl_hooks
except ImportError:
print "ERROR: Could not import git_cl_hooks from depot_tools in your PATH."
print "ERROR: Make sure %s is up-to-date and try again." % depot_tools_path
sys.exit(1)
# Ensure we were called with the necessary number of arguments.
program_name = os.path.basename(sys.argv[0])
if len(sys.argv) != 2:
print "usage: %s [upstream branch]" % program_name
sys.exit(1)
# Run the hooks library with our arguments.
exec git_cl_hooks.RunHooks(hook_name=program_name, upstream_branch=sys.argv[1])