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

Side by Side Diff: git-cl-upload-hook

Issue 6312034: Enforce inserting the depot_tools path as the first path in sys.path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 os 6 import os
7 import sys 7 import sys
8 from subprocess import Popen, PIPE 8 from subprocess import Popen, PIPE
9 9
10 # Try locating depot_tools from the user's PATH. 10 # Try locating depot_tools from the user's PATH.
(...skipping 10 matching lines...) Expand all
21 if not depot_tools_path: 21 if not depot_tools_path:
22 # Grab a `which gclient', which gives first match 22 # Grab a `which gclient', which gives first match
23 # `which' also uses PATH, but is not restricted to specific directory name 23 # `which' also uses PATH, but is not restricted to specific directory name
24 path = Popen(["which", "gclient"], stdout=PIPE).communicate()[0].strip() 24 path = Popen(["which", "gclient"], stdout=PIPE).communicate()[0].strip()
25 if path: 25 if path:
26 depot_tools_path = path.replace("/gclient","") 26 depot_tools_path = path.replace("/gclient","")
27 27
28 # If we found depot_tools, add it to the script's import path. 28 # If we found depot_tools, add it to the script's import path.
29 # Use realpath to normalize the actual path 29 # Use realpath to normalize the actual path
30 if depot_tools_path: 30 if depot_tools_path:
31 sys.path.append(os.path.realpath(depot_tools_path)) 31 sys.path.insert(0, os.path.realpath(depot_tools_path))
32 else: 32 else:
33 print "ERROR: Could not find depot_tools in your PATH." 33 print "ERROR: Could not find depot_tools in your PATH."
34 print "ERROR: Please add it to your PATH and try again." 34 print "ERROR: Please add it to your PATH and try again."
35 sys.exit(1) 35 sys.exit(1)
36 36
37 # Try importing git_cl_hooks from depot_tools. 37 # Try importing git_cl_hooks from depot_tools.
38 try: 38 try:
39 import git_cl_hooks 39 import git_cl_hooks
40 except ImportError: 40 except ImportError:
41 print "ERROR: Could not import git_cl_hooks from depot_tools in your PATH." 41 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 42 print "ERROR: Make sure %s is up-to-date and try again." % depot_tools_path
43 sys.exit(1) 43 sys.exit(1)
44 44
45 # Ensure we were called with the necessary number of arguments. 45 # Ensure we were called with the necessary number of arguments.
46 program_name = os.path.basename(sys.argv[0]) 46 program_name = os.path.basename(sys.argv[0])
47 if len(sys.argv) != 2: 47 if len(sys.argv) != 2:
48 print "usage: %s [upstream branch]" % program_name 48 print "usage: %s [upstream branch]" % program_name
49 sys.exit(1) 49 sys.exit(1)
50 50
51 # Run the hooks library with our arguments. 51 # Run the hooks library with our arguments.
52 exec git_cl_hooks.RunHooks(hook_name=program_name, upstream_branch=sys.argv[1]) 52 exec git_cl_hooks.RunHooks(hook_name=program_name, upstream_branch=sys.argv[1])
OLDNEW
« 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