Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed #3058 issue #3060

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/git/config.go
Expand Up @@ -50,8 +50,8 @@ func ExtractRepoFromURL(rawurl string) (config.Repo, error) {
// split the parsed url path by /, the last parts should be the owner and name
ss := strings.Split(strings.TrimPrefix(u.Path, "/"), "/")

// if less than 2 parts, its likely not a valid repository
if len(ss) < 2 {
// if path doesn't contain any item, its likely not a valid repository
if len(ss) == 0 {
return config.Repo{}, fmt.Errorf("unsupported repository URL: %s", rawurl)
}
repo := config.Repo{
Expand Down
5 changes: 3 additions & 2 deletions internal/git/config_test.go
Expand Up @@ -50,6 +50,7 @@ func TestExtractRepoFromURL(t *testing.T) {
for _, url := range []string{
"git@github.com:goreleaser/goreleaser.git",
"git@custom:goreleaser/goreleaser.git",
"ssh://username@git.example.com/goreleaser",
"https://foo@github.com/goreleaser/goreleaser",
"https://github.com/goreleaser/goreleaser.git",
"https://something.with.port:8080/goreleaser/goreleaser.git",
Expand Down Expand Up @@ -78,8 +79,8 @@ func TestExtractRepoFromURL(t *testing.T) {

// invalid urls
for _, url := range []string{
"git@gist.github.com:someid.git",
"https://gist.github.com/someid.git",
"git@gist.github.com:",
"https://gist.github.com/",
} {
t.Run(url, func(t *testing.T) {
repo, err := git.ExtractRepoFromURL(url)
Expand Down