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

Unified Diff: git-cl-upload-hook

Issue 2852032: git-cl-upload-hook: improved finding depot_tools algorithm... (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: '' Created 10 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git-cl-upload-hook
===================================================================
--- git-cl-upload-hook (revision 51063)
+++ git-cl-upload-hook (working copy)
@@ -5,18 +5,30 @@
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"):
+ 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]
+ 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.append(depot_tools_path)
+ sys.path.append(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."
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698