Bail out only if depot_tools path contains a tilde

Previously, gclient will exit if it found a tilde in any element from
PATH. This CL changes that to first check if the path is the actual
depot_tools directory.

Also check for '~', instead of '~/', in case the path looks like
'~user/path/to/depot_tools/.

Bug: 952865
Change-Id: Ied07444e44edb655b5c8837b5e51eeb0dcebba6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1581419
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
changes/19/1581419/2
Henrique Ferreiro 6 years ago committed by Commit Bot
parent 623238e186
commit 4ef3221c5d

@ -125,6 +125,8 @@ except NameError:
basestring = str basestring = str
DEPOT_TOOLS_DIR = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
# Singleton object to represent an unset cache_dir (as opposed to a disabled # Singleton object to represent an unset cache_dir (as opposed to a disabled
# one, e.g. if a spec explicitly says `cache_dir = None`.) # one, e.g. if a spec explicitly says `cache_dir = None`.)
UNSET_CACHE_DIR = object() UNSET_CACHE_DIR = object()
@ -3100,7 +3102,8 @@ def disable_buffering():
def path_contains_tilde(): def path_contains_tilde():
for element in os.environ['PATH'].split(os.pathsep): for element in os.environ['PATH'].split(os.pathsep):
if element.startswith('~/'): if element.startswith('~') and os.path.abspath(
os.path.realpath(os.path.expanduser(element))) == DEPOT_TOOLS_DIR:
return True return True
return False return False

Loading…
Cancel
Save