diff --git a/clearml_agent/helper/repo.py b/clearml_agent/helper/repo.py index 8d1e427..833951b 100644 --- a/clearml_agent/helper/repo.py +++ b/clearml_agent/helper/repo.py @@ -219,12 +219,15 @@ def remote_branch_name(branch): return branch # parse scp-like git ssh URLs, e.g: git@host:user/project.git + # or git@ssh.dev.azure.com:v3/org/project/repo SSH_URL_GIT_SYNTAX = re.compile( r""" ^ (?:(?P{regular}*?)@)? + (?:ssh\.)? (?P{regular}*?) : + (?:v3/)? (?P{regular}.*)? $ """.format( @@ -253,6 +256,14 @@ def get_username(user_, password=None): match = cls.SSH_URL_GIT_SYNTAX.match(url) if match: user, host, path = match.groups() + + # handle the dev.azure format by inserting _git between project and repo + # as format is https://dev.azure.com/{organization}/{project}/_git/{repo} + if "azure" in host: + path_components = path.split("/") + path_components.insert(-1, "_git") + path = "/".join(path_components) + return ( furl() .set(scheme="https", username=get_username(user), host=host, path=path) diff --git a/tests/package/ssh_conversion.py b/tests/package/ssh_conversion.py index 7f2084c..8aef238 100644 --- a/tests/package/ssh_conversion.py +++ b/tests/package/ssh_conversion.py @@ -16,6 +16,7 @@ ("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"),