feat: generic git https (#73)

Previously, only `github.com` was supported for HTTP cloning of packages.

With this change, every git host using the http protocol (GitHub, Gitlab, Gitea) is supported :D
This commit is contained in:
Cody Boggs 2020-02-03 10:07:44 -07:00 committed by GitHub
parent 8f14d63f95
commit 0ba0ff5522
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 127 additions and 19 deletions

View file

@ -67,6 +67,108 @@ func TestParseGit(t *testing.T) {
want: sshWant("my.host"),
wantRemote: "ssh://git@my.host/user/repo.git", // want ssh format here
},
{
name: "ValidGitHTTPS",
uri: "https://example.com/foo/bar",
want: &Dependency{
Version: "master",
Source: Source{
GitSource: &Git{
Scheme: GitSchemeHTTPS,
Host: "example.com",
User: "foo",
Repo: "bar",
Subdir: "",
},
},
},
wantRemote: "https://example.com/foo/bar",
},
{
name: "ValidGitNoScheme",
uri: "example.com/foo/bar",
want: &Dependency{
Version: "master",
Source: Source{
GitSource: &Git{
Scheme: GitSchemeHTTPS,
Host: "example.com",
User: "foo",
Repo: "bar",
Subdir: "",
},
},
},
wantRemote: "https://example.com/foo/bar",
},
{
name: "ValidGitPath",
uri: "example.com/foo/bar/baz/bat",
want: &Dependency{
Version: "master",
Source: Source{
GitSource: &Git{
Scheme: GitSchemeHTTPS,
Host: "example.com",
User: "foo",
Repo: "bar",
Subdir: "/baz/bat",
},
},
},
wantRemote: "https://example.com/foo/bar",
},
{
name: "ValidGitVersion",
uri: "example.com/foo/bar@baz",
want: &Dependency{
Version: "baz",
Source: Source{
GitSource: &Git{
Scheme: GitSchemeHTTPS,
Host: "example.com",
User: "foo",
Repo: "bar",
Subdir: "",
},
},
},
wantRemote: "https://example.com/foo/bar",
},
{
name: "ValidGitPathVersion",
uri: "example.com/foo/bar/baz@bat",
want: &Dependency{
Version: "bat",
Source: Source{
GitSource: &Git{
Scheme: GitSchemeHTTPS,
Host: "example.com",
User: "foo",
Repo: "bar",
Subdir: "/baz",
},
},
},
wantRemote: "https://example.com/foo/bar",
},
{
name: "ValidGitSubdomain",
uri: "git.example.com/foo/bar",
want: &Dependency{
Version: "master",
Source: Source{
GitSource: &Git{
Scheme: GitSchemeHTTPS,
Host: "git.example.com",
User: "foo",
Repo: "bar",
Subdir: "",
},
},
},
wantRemote: "https://git.example.com/foo/bar",
},
}
for _, c := range tests {