From 4821259f010768c382b6ba555ff457b4adf094d0 Mon Sep 17 00:00:00 2001 From: Katrina Verey Date: Fri, 6 Jan 2023 16:53:52 -0500 Subject: [PATCH] Stop handling mysterious gh: prefix in remote URLs --- api/internal/git/repospec.go | 6 ++---- api/internal/git/repospec_test.go | 6 ++++-- api/internal/localizer/util_test.go | 4 ---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/api/internal/git/repospec.go b/api/internal/git/repospec.go index c536b8c12..748be7724 100644 --- a/api/internal/git/repospec.go +++ b/api/internal/git/repospec.go @@ -234,10 +234,8 @@ func extractHost(n string) (string, string) { n, _ = trimPrefixIgnoreCase(n, "git::") scheme, n := extractScheme(n) - if scheme == "file://" || scheme == "gh:" { - // We support gh: assuming authors use it as a github shorthand, specified in .gitconfig. + if scheme == "file://" { // The file protocol specifies an absolute path to a local git repo. There is no host. - // In both cases, we return the scheme and the rest of the url. return scheme, n } @@ -264,7 +262,7 @@ func validHostSpecParsed(scheme, username, host string) bool { } func extractScheme(s string) (string, string) { - for _, prefix := range []string{"gh:", "ssh://", "https://", "http://", "file://"} { + for _, prefix := range []string{"ssh://", "https://", "http://", "file://"} { if rest, found := trimPrefixIgnoreCase(s, prefix); found { return prefix, rest } diff --git a/api/internal/git/repospec_test.go b/api/internal/git/repospec_test.go index 603631758..310ae32b1 100644 --- a/api/internal/git/repospec_test.go +++ b/api/internal/git/repospec_test.go @@ -19,8 +19,6 @@ func TestNewRepoSpecFromUrl_Permute(t *testing.T) { // we probably stil don't want to break backwards compatibility for things // that are unintentionally supported. var schemeAuthority = []struct{ raw, normalized string }{ - {"gh:", "gh:"}, - {"GH:", "gh:"}, {"gitHub.com/", "https://github.com/"}, {"github.com:", "https://github.com/"}, {"http://github.com/", "https://github.com/"}, @@ -126,6 +124,10 @@ func TestNewRepoSpecFromUrlErrors(t *testing.T) { "git@https://github.com/org/repo.git//path", "url lacks host", }, + "mysterious gh: prefix previously supported is no longer handled": { + "gh:org/repo", + "url lacks orgRepo", + }, } for name, testCase := range badData { diff --git a/api/internal/localizer/util_test.go b/api/internal/localizer/util_test.go index ce70b4c01..91fca64ce 100644 --- a/api/internal/localizer/util_test.go +++ b/api/internal/localizer/util_test.go @@ -226,10 +226,6 @@ func TestLocRootPath_URLComponents(t *testing.T) { urlf: "file:///var/run/repo//%s?ref=value", path: simpleJoin(t, FileSchemeDir, "var", "run", "repo", "value"), }, - "gh_shorthand": { - urlf: "gh:org/repo//%s?ref=value", - path: simpleJoin(t, "gh", "org", "repo", "value"), - }, "IPv6": { urlf: "https://[2001:4860:4860::8888]/org/repo//%s?ref=value", path: simpleJoin(t, "2001:4860:4860::8888", "org", "repo", "value"),