From edbd72d5306c6bd072c4e0fccd72976ccd2b805e Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Jul 10 2024 13:48:45 +0000 Subject: Only add git+ssh:// for git@ repo paths Fixes an issue introduced by ad46d3458143447f3fc6174d243c9f8ff6df3454 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 --- diff --git a/src/centpkg/utils.py b/src/centpkg/utils.py index 9806613..4a420f9 100644 --- a/src/centpkg/utils.py +++ b/src/centpkg/utils.py @@ -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") 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/... # 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