improve url parsing function in gitcloner

This commit is contained in:
Jingfang Liu
2018-12-13 10:35:03 -08:00
parent b971e6a1da
commit 20e37eaf65
2 changed files with 29 additions and 4 deletions

View File

@@ -52,6 +52,14 @@ func TestIsRepoURL(t *testing.T) {
input: "git::https://gitlab.com/org/repo",
expected: true,
},
{
input: "git@gitlab2.sqtools.ru:10022/infra/kubernetes/thanos-base.git?ref=v0.1.0",
expected: true,
},
{
input: "git@bitbucket.org:org/repo.git",
expected: true,
},
{
input: "/github.com/org/repo",
expected: false,
@@ -283,6 +291,12 @@ func TestParseUrl(t *testing.T) {
path: "somedir",
ref: "",
},
{
input: "git@gitlab2.sqtools.ru:10022/infra/kubernetes/thanos-base.git?ref=v0.1.0",
repo: "git@gitlab2.sqtools.ru:10022/infra/kubernetes/thanos-base.git",
path: "",
ref: "v0.1.0",
},
}
for _, testcase := range testcases {
repo, path, ref, err := parseUrl(testcase.input)