depot_tools: Fix gclient_test on Windows.
Bug: 1007580
Change-Id: I8265b3f4e64b95d7f107b50eb8c68983d6002468
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1828080
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
diff --git a/git_cache.py b/git_cache.py
index 8d050c3..4d3892d 100755
--- a/git_cache.py
+++ b/git_cache.py
@@ -69,7 +69,7 @@
Returns: The return value of the successful fn.
"""
printerr = printerr or logging.warning
- for i in xrange(count):
+ for i in range(count):
try:
return fn()
except excs as e:
@@ -268,7 +268,13 @@
def UrlToCacheDir(url):
"""Convert a git url to a normalized form for the cache dir path."""
parsed = urlparse.urlparse(url)
- norm_url = parsed.netloc + parsed.path
+ # Get rid of the port. This is only needed for Windows tests, since tests
+ # serve git from git://localhost:port/git, but Windows doesn't like ':' in
+ # paths.
+ netloc = parsed.netloc
+ if ':' in netloc:
+ netloc = netloc.split(':', 1)[0]
+ norm_url = netloc + parsed.path
if norm_url.endswith('.git'):
norm_url = norm_url[:-len('.git')]