2020-07-09 16:40:37 -04:00
|
|
|
package git_test
|
2017-01-14 19:12:20 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-07-09 16:40:37 -04:00
|
|
|
"github.com/goreleaser/goreleaser/internal/git"
|
2017-10-15 17:46:21 -02:00
|
|
|
"github.com/goreleaser/goreleaser/internal/testlib"
|
2020-10-06 09:48:04 -03:00
|
|
|
"github.com/stretchr/testify/require"
|
2017-01-14 19:12:20 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestRepoName(t *testing.T) {
|
2020-12-12 13:27:35 -03:00
|
|
|
testlib.Mktmp(t)
|
2017-10-15 17:46:21 -02:00
|
|
|
testlib.GitInit(t)
|
|
|
|
testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git")
|
2020-07-09 16:40:37 -04:00
|
|
|
repo, err := git.ExtractRepoFromConfig()
|
2020-10-06 09:48:04 -03:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, "goreleaser/goreleaser", repo.String())
|
2017-01-14 19:12:20 +01:00
|
|
|
}
|
|
|
|
|
2018-02-20 18:21:20 -03:00
|
|
|
func TestExtractRepoFromURL(t *testing.T) {
|
|
|
|
for _, url := range []string{
|
|
|
|
"git@github.com:goreleaser/goreleaser.git",
|
|
|
|
"git@custom:goreleaser/goreleaser.git",
|
|
|
|
"git@custom:crazy/url/goreleaser/goreleaser.git",
|
|
|
|
"https://github.com/goreleaser/goreleaser.git",
|
|
|
|
"https://github.enterprise.com/goreleaser/goreleaser.git",
|
|
|
|
"https://github.enterprise.com/crazy/url/goreleaser/goreleaser.git",
|
|
|
|
} {
|
|
|
|
t.Run(url, func(t *testing.T) {
|
2020-07-09 16:40:37 -04:00
|
|
|
repo := git.ExtractRepoFromURL(url)
|
2020-10-06 09:48:04 -03:00
|
|
|
require.Equal(t, "goreleaser/goreleaser", repo.String())
|
2018-02-20 18:21:20 -03:00
|
|
|
})
|
|
|
|
}
|
2017-01-14 19:12:20 +01:00
|
|
|
}
|