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

Unified Diff: git_cl/test/git-cl-test-hook

Issue 6646009: update git-cl for OWNERS file support via .git/hooks/pre-cl-* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: clean up after running owners-related git-cl tests 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « git_cl/git_cl.py ('k') | git_cl/test/owners.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cl/test/git-cl-test-hook
diff --git a/git_cl/test/git-cl-test-hook b/git_cl/test/git-cl-test-hook
new file mode 100755
index 0000000000000000000000000000000000000000..8bc194c9a607f95acb3d4dc952088048f0a85312
--- /dev/null
+++ b/git_cl/test/git-cl-test-hook
@@ -0,0 +1,60 @@
+#!/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 optparse
+import os
+import sys
+from subprocess import Popen, PIPE
+
+# Try locating depot_tools from the user's PATH.
+depot_tools_path = None
+
+# First parse PATH if there's a "depot_tools" inside
+for path in os.environ.get("PATH").split(os.pathsep):
+ if not path.endswith("depot_tools") and not path.endswith("depot_tools/"):
+ continue
+ depot_tools_path = path
+ break
+
+# If depot_tools dir is not called depot_tools, or other weirdness
+if not depot_tools_path:
+ # Grab a `which gclient', which gives first match
+ # `which' also uses PATH, but is not restricted to specific directory name
+ path = Popen(["which", "gclient"], stdout=PIPE).communicate()[0].strip()
+ if path:
+ depot_tools_path = path.replace("/gclient","")
+
+# If we found depot_tools, add it to the script's import path.
+# Use realpath to normalize the actual path
+if depot_tools_path:
+ sys.path.insert(0, os.path.realpath(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)
+
+parser = optparse.OptionParser()
+parser.set_usage('%prog [options] <upstream-branch>')
+parser.add_option('--tbr', action='store_true', default=False,
+ help='skip checks for reviewers, owners')
+parser.add_option('--host-url', default=None,
+ help='scheme, origin, and port for Rietveld server')
+options, args = parser.parse_args()
+if len(args) != 1:
+ parser.print_help()
+ sys.exit(1)
+
+# Run the hooks library with our arguments.
+exec git_cl_hooks.RunHooks(hook_name=parser.get_prog_name(),
+ upstream_branch=args[0],
+ cmd_line_options=options)
« no previous file with comments | « git_cl/git_cl.py ('k') | git_cl/test/owners.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698