Skip to content

Commit

Permalink
fix: fail if cant guess project name (#1378)
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
  • Loading branch information
caarlos0 committed Mar 4, 2020
1 parent 9ba0439 commit 5efb690
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/pipe/project/project.go
@@ -1,7 +1,11 @@
// Package project sets "high level" defaults related to the project.
package project

import "github.com/goreleaser/goreleaser/pkg/context"
import (
"fmt"

"github.com/goreleaser/goreleaser/pkg/context"
)

// Pipe implemens defaulter to set the project name
type Pipe struct{}
Expand All @@ -20,6 +24,8 @@ func (Pipe) Default(ctx *context.Context) error {
ctx.Config.ProjectName = ctx.Config.Release.GitLab.Name
case ctx.Config.Release.Gitea.Name != "":
ctx.Config.ProjectName = ctx.Config.Release.Gitea.Name
default:
return fmt.Errorf("couldn't guess project_name, please add it to your config")
}
}
return nil
Expand Down
9 changes: 9 additions & 0 deletions internal/pipe/project/project_test.go
Expand Up @@ -61,3 +61,12 @@ func TestEmptyProjectName_DefaultsToGiteaRelease(t *testing.T) {
require.NoError(t, Pipe{}.Default(ctx))
require.Equal(t, "bar", ctx.Config.ProjectName)
}

func TestEmptyProjectNameAndRelease(t *testing.T) {
var ctx = context.New(config.Project{
Release: config.Release{
GitHub: config.Repo{},
},
})
require.EqualError(t, Pipe{}.Default(ctx), "couldn't guess project_name, please add it to your config")
}

0 comments on commit 5efb690

Please sign in to comment.