Fix ssh to http conversion for azure devops repos

This commit is contained in:
Mads Oestergaard 2024-01-29 14:39:22 +01:00
parent 95dde6ca0c
commit 04fa8a9a86
2 changed files with 12 additions and 0 deletions

View File

@ -225,6 +225,7 @@ class VCS(object):
(?:(?P<user>{regular}*?)@)?
(?P<host>{regular}*?)
:
(?:v3/)? # present in azure ssh urls
(?P<path>{regular}.*)?
$
""".format(
@ -253,6 +254,16 @@ class VCS(object):
match = cls.SSH_URL_GIT_SYNTAX.match(url)
if match:
user, host, path = match.groups()
# handle special azure cases
if "ssh" and "azure" in host:
host = host.replace("ssh.", "")
# azure http url is different than ssh url
# the format is https://dev.azure.com/{organization}/{project}/_git/{repo}
path_components = path.split("/")
path = "/".join(path_components[:-1]) + "/_git/" + path_components[-1]
return (
furl()
.set(scheme="https", username=get_username(user), host=host, path=path)

View File

@ -16,6 +16,7 @@ from clearml_agent.helper.repo import VCS
("ftp://example.com/a/b/", None),
("github.com:foo/bar.git", "https://github.com/foo/bar.git"),
("git@github.com:foo/bar.git", "https://github.com/foo/bar.git"),
("git@ssh.dev.azure.com:v3/org/project/repo", "https://dev.azure.com/org/project/_git/repo"),
("bitbucket.org:foo/bar.git", "https://bitbucket.org/foo/bar.git"),
("hg@bitbucket.org:foo/bar.git", "https://bitbucket.org/foo/bar.git"),
("ssh://bitbucket.org/foo/bar.git", "https://bitbucket.org/foo/bar.git"),