diff --git a/git/url.go b/git/url.go index 7d4aac4d7..1a3e97fd6 100644 --- a/git/url.go +++ b/git/url.go @@ -14,6 +14,7 @@ func isSupportedProtocol(u string) bool { strings.HasPrefix(u, "git+ssh:") || strings.HasPrefix(u, "git:") || strings.HasPrefix(u, "http:") || + strings.HasPrefix(u, "git+https:") || strings.HasPrefix(u, "https:") } @@ -43,6 +44,10 @@ func ParseURL(rawURL string) (u *url.URL, err error) { u.Scheme = "ssh" } + if u.Scheme == "git+https" { + u.Scheme = "https" + } + if u.Scheme != "ssh" { return } diff --git a/git/url_test.go b/git/url_test.go index 679739b41..f5b3b50d0 100644 --- a/git/url_test.go +++ b/git/url_test.go @@ -28,11 +28,26 @@ func TestIsURL(t *testing.T) { url: "git://example.com/owner/repo", want: true, }, + { + name: "git with extension", + url: "git://example.com/owner/repo.git", + want: true, + }, + { + name: "git+ssh", + url: "git+ssh://git@example.com/owner/repo.git", + want: true, + }, { name: "https", url: "https://example.com/owner/repo.git", want: true, }, + { + name: "git+https", + url: "git+https://example.com/owner/repo.git", + want: true, + }, { name: "no protocol", url: "example.com/owner/repo", @@ -121,6 +136,16 @@ func TestParseURL(t *testing.T) { Path: "/owner/repo.git", }, }, + { + name: "git+https", + url: "git+https://example.com/owner/repo.git", + want: url{ + Scheme: "https", + User: "", + Host: "example.com", + Path: "/owner/repo.git", + }, + }, { name: "scp-like", url: "git@example.com:owner/repo.git",