2018-03-12 08:42:31 -03:00
|
|
|
// Package project sets "high level" defaults related to the project.
|
|
|
|
package project
|
|
|
|
|
2020-03-04 16:03:05 -03:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
|
|
|
)
|
2018-03-12 08:42:31 -03:00
|
|
|
|
2020-05-26 00:48:10 -03:00
|
|
|
// Pipe implemens defaulter to set the project name.
|
2018-03-12 08:42:31 -03:00
|
|
|
type Pipe struct{}
|
|
|
|
|
|
|
|
func (Pipe) String() string {
|
|
|
|
return "project name"
|
|
|
|
}
|
|
|
|
|
2020-05-26 00:48:10 -03:00
|
|
|
// Default set project defaults.
|
2018-03-12 08:42:31 -03:00
|
|
|
func (Pipe) Default(ctx *context.Context) error {
|
|
|
|
if ctx.Config.ProjectName == "" {
|
2020-02-26 12:38:07 +00:00
|
|
|
switch {
|
|
|
|
case ctx.Config.Release.GitHub.Name != "":
|
|
|
|
ctx.Config.ProjectName = ctx.Config.Release.GitHub.Name
|
|
|
|
case ctx.Config.Release.GitLab.Name != "":
|
|
|
|
ctx.Config.ProjectName = ctx.Config.Release.GitLab.Name
|
|
|
|
case ctx.Config.Release.Gitea.Name != "":
|
|
|
|
ctx.Config.ProjectName = ctx.Config.Release.Gitea.Name
|
2020-03-04 16:03:05 -03:00
|
|
|
default:
|
|
|
|
return fmt.Errorf("couldn't guess project_name, please add it to your config")
|
2020-02-26 12:38:07 +00:00
|
|
|
}
|
2018-03-12 08:42:31 -03:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|