ad46d3
Fix autodetection of repo name with SSH remote
@@ -197,9 +197,18 @@ def get_canonical_repo_name(config, repo_url):
|
|
197
197
|
distgit_section = '{0}.distgit'.format(cli_name)
|
198
198
|
distgit_api_base_url = config_get_safely(dist_git_config, distgit_section, "apibaseurl")
|
199
199
|
|
200
|
-
# Make sure the fork comes from the same Gitlab instance
|
201
200
|
parsed_repo_url = urlparse(repo_url)
|
202
|
-
|
201
|
+
if not parsed_repo_url.scheme:
|
202
|
+
# Some git checkouts are in the form of git@gitlab.com/...
|
203
|
+
# If it's missing the scheme, it will treat the entire URL as the path
|
204
|
+
# so we'll fake up the scheme for this situation
|
205
|
+
# https://www.git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository
|
206
|
+
# implies that no scheme is equivalent to git+ssh://
|
207
|
+
# When making that conversion, we also have to replace the leading ':'
|
208
|
+
# with a slash.
|
209
|
+
faked_url = "git+ssh://{0}".format(repo_url.replace(":", "/", 1))
|
210
|
+
parsed_repo_url = urlparse(faked_url)
|
211
|
+
|
203
212
|
|
204
213
|
try:
|
205
214
|
distgit_token = config_get_safely(dist_git_config, distgit_section, 'token')
|
@@ -228,7 +237,7 @@ def get_canonical_repo_name(config, repo_url):
|
|
228
237
|
|
229
238
|
except Exception as e:
|
230
239
|
# For any other exception, just fall back to using the last segment
|
231
|
-
# of the URL path
|
240
|
+
# of the URL path and hope it's correct
|
232
241
|
canonical_repo_name = parsed_repo_url.path.split('/')[-1]
|
233
242
|
|
234
243
|
# Chop off a trailing .git if any
|