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

This commit is contained in:
allegroai 2023-12-20 17:48:18 +02:00
parent 7c3e420df4
commit 3dd8d783e1

View File

@ -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: