From 3dd8d783e1992c5140a679f2ca0ed93c8d318efd Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Wed, 20 Dec 2023 17:48:18 +0200 Subject: [PATCH] Fix `agent.git_host` setting will cause git@domain URLs to not be replaced by SSH URLs since furl cannot parse them to obtain host --- clearml_agent/helper/repo.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/clearml_agent/helper/repo.py b/clearml_agent/helper/repo.py index 28cd77d..8d1e427 100644 --- a/clearml_agent/helper/repo.py +++ b/clearml_agent/helper/repo.py @@ -346,11 +346,18 @@ class VCS(object): # if we have git_user / git_pass replace ssh credentials with https authentication if (ENV_AGENT_GIT_USER.get() or self.session.config.get('agent.git_user', None)) and \ (ENV_AGENT_GIT_PASS.get() or self.session.config.get('agent.git_pass', None)): + # only apply to a specific domain (if requested) config_domain = \ ENV_AGENT_GIT_HOST.get() or self.session.config.get("agent.git_host", None) - if config_domain and config_domain != furl(self.url).host: - return + if config_domain: + if config_domain != furl(self.url).host: + # bail out here if we have a git_host configured and it's different than the URL host + # however, we should make sure this is not an ssh@ URL that furl failed to parse + ssh_git_url_match = self.SSH_URL_GIT_SYNTAX.match(self.url) + if not ssh_git_url_match or config_domain != ssh_git_url_match.groupdict().get("host"): + # do not replace to ssh url + return new_url = self.replace_ssh_url(self.url) if new_url != self.url: