Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions clearml_agent/helper/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<user>{regular}*?)@)?
(?:ssh\.)?
(?P<host>{regular}*?)
:
(?:v3/)?
(?P<path>{regular}.*)?
$
""".format(
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions tests/package/ssh_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down