[git_cache] support ssh url

Paths containing ':' characters are illegal only on Windows platforms.
So, ssh_url like git@github.com:chromium/chromium.git will generate
runtime exception on Windows. We replace ':' with '__' to avoid
exceptions in the ssh form of git_url case.

R=ddoman@chromium.org

Bug: 329781388

Change-Id: Ia4db6a0927b40b521477e5d90addb4056c2c8ef8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5369296
Auto-Submit: 吴金立 <wujinli.cn@gmail.com>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Joanna Wang <jojwang@chromium.org>
This commit is contained in:
Jinli Wu
2024-03-26 14:24:43 +00:00
committed by LUCI CQ
parent 7209f68326
commit 89588ed8f2
2 changed files with 16 additions and 0 deletions

View File

@@ -176,6 +176,8 @@ class Mirror(object):
# Use the same dir for authenticated URLs and unauthenticated URLs.
norm_url = norm_url.replace('googlesource.com/a/', 'googlesource.com/')
norm_url = norm_url.replace(':', '__')
return norm_url.replace('-', '--').replace('/', '-').lower()
@staticmethod
@@ -183,6 +185,12 @@ class Mirror(object):
"""Convert a cache dir path to its corresponding url."""
netpath = re.sub(r'\b-\b', '/',
os.path.basename(path)).replace('--', '-')
netpath = netpath.replace('__', ':')
if netpath.startswith('git@'):
return netpath
return 'https://%s' % netpath
@classmethod