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