Only add git+ssh:// for git@ repo paths

Fixes an issue introduced by ad46d34581

Apparently, under some circumstances, rpkg will store the "repo name" as
only the path field when using HTTPS remotes. As a result, we were
incorrectly treating those paths as an SSH URI since they had no scheme
when parsed by urllib.parse.urlparse(). This resulted in the first part
of the path being treated as the "netloc" and being trimmed out. This
naturally meant that the lookup against Gitlab for the fork parent would
fail.

This patch adds a check to ensure that the git+ssh:// scheme is only
added if the repo_url starts with "git@".

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
This commit is contained in:
Stephen Gallagher 2024-07-10 09:48:45 -04:00
parent 8c605fd2ee
commit edbd72d530

View file

@ -199,7 +199,7 @@ def get_canonical_repo_name(config, repo_url):
distgit_api_base_url = config_get_safely(dist_git_config, distgit_section, "apibaseurl") distgit_api_base_url = config_get_safely(dist_git_config, distgit_section, "apibaseurl")
parsed_repo_url = urlparse(repo_url) parsed_repo_url = urlparse(repo_url)
if not parsed_repo_url.scheme: if not parsed_repo_url.scheme and repo_url.startswith("git@"):
# Some git checkouts are in the form of git@gitlab.com/... # Some git checkouts are in the form of git@gitlab.com/...
# If it's missing the scheme, it will treat the entire URL as the path # If it's missing the scheme, it will treat the entire URL as the path
# so we'll fake up the scheme for this situation # so we'll fake up the scheme for this situation