1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-11-06 09:09:29 +02:00

fix: git url with port (#2705)

closes #2704

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker
2021-11-28 10:35:01 -03:00
committed by GitHub
parent e8fca30104
commit 09aec7ca2e
2 changed files with 14 additions and 4 deletions

View File

@@ -38,10 +38,6 @@ func ExtractRepoFromURL(rawurl string) (config.Repo, error) {
// Gitlab-CI uses this type of URL // Gitlab-CI uses this type of URL
if strings.Count(s, ":") == 1 { if strings.Count(s, ":") == 1 {
s = s[strings.LastIndex(s, ":")+1:] s = s[strings.LastIndex(s, ":")+1:]
} else {
// Handle Gitlab-ci funky URLs in the form of:
// "https://gitlab-ci-token:SOME_TOKEN@gitlab.yourcompany.com/yourgroup/yourproject.git"
s = "//" + s[strings.LastIndex(s, "@")+1:]
} }
// now we can parse it with net/url // now we can parse it with net/url

View File

@@ -8,6 +8,19 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
func TestNotARepo(t *testing.T) {
testlib.Mktmp(t)
_, err := git.ExtractRepoFromConfig()
require.EqualError(t, err, `current folder is not a git repository`)
}
func TestNoRemote(t *testing.T) {
testlib.Mktmp(t)
testlib.GitInit(t)
_, err := git.ExtractRepoFromConfig()
require.EqualError(t, err, `no remote configured to list refs from`)
}
func TestRepoName(t *testing.T) { func TestRepoName(t *testing.T) {
testlib.Mktmp(t) testlib.Mktmp(t)
testlib.GitInit(t) testlib.GitInit(t)
@@ -37,6 +50,7 @@ func TestExtractRepoFromURL(t *testing.T) {
"git@custom:goreleaser/goreleaser.git", "git@custom:goreleaser/goreleaser.git",
"https://foo@github.com/goreleaser/goreleaser", "https://foo@github.com/goreleaser/goreleaser",
"https://github.com/goreleaser/goreleaser.git", "https://github.com/goreleaser/goreleaser.git",
"https://something.with.port:8080/goreleaser/goreleaser.git",
"https://github.enterprise.com/goreleaser/goreleaser.git", "https://github.enterprise.com/goreleaser/goreleaser.git",
"https://gitlab-ci-token:SOME_TOKEN@gitlab.yourcompany.com/goreleaser/goreleaser.git", "https://gitlab-ci-token:SOME_TOKEN@gitlab.yourcompany.com/goreleaser/goreleaser.git",
} { } {