From f640eb67078283cb16e66c629c76375ab3e1fdee Mon Sep 17 00:00:00 2001 From: Mads Oestergaard Date: Fri, 2 Feb 2024 10:50:52 +0100 Subject: [PATCH] Move ssh filter into regex and use list.insert in path --- clearml_agent/helper/repo.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/clearml_agent/helper/repo.py b/clearml_agent/helper/repo.py index 403a60b..833951b 100644 --- a/clearml_agent/helper/repo.py +++ b/clearml_agent/helper/repo.py @@ -219,13 +219,15 @@ class VCS(object): 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/)? # present in azure ssh urls + (?:v3/)? (?P{regular}.*)? $ """.format( @@ -255,14 +257,12 @@ class VCS(object): 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} + # 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 = "/".join(path_components[:-1]) + "/_git/" + path_components[-1] + path_components.insert(-1, "_git") + path = "/".join(path_components) return ( furl()