gitutil: infer submodule with baseURL when it is a relative path (#6337)

This commit is contained in:
ᴜɴᴋɴᴡᴏɴ
2020-09-18 16:19:31 +08:00
committed by GitHub
parent 8b75e9a442
commit dda1092e74
6 changed files with 28 additions and 8 deletions

View File

@@ -41,6 +41,14 @@ func TestInferSubmoduleURL(t *testing.T) {
},
expURL: "http://github.com/gogs/docs-api/commit/6b08f76a5313fa3d26859515b30aa17a5faa2807",
},
{
name: "relative path",
submodule: &git.Submodule{
URL: "../repo2.git",
Commit: "6b08f76a5313fa3d26859515b30aa17a5faa2807",
},
expURL: "https://gogs.example.com/user/repo/../repo2/commit/6b08f76a5313fa3d26859515b30aa17a5faa2807",
},
{
name: "bad URL",
submodule: &git.Submodule{
@@ -52,7 +60,7 @@ func TestInferSubmoduleURL(t *testing.T) {
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assert.Equal(t, test.expURL, InferSubmoduleURL(test.submodule))
assert.Equal(t, test.expURL, InferSubmoduleURL("https://gogs.example.com/user/repo", test.submodule))
})
}
}