github.com/goreleaser/goreleaser@v1.25.1/internal/commitauthor/author.go (about) 1 // Package commitauthor provides common commit author functionality. 2 package commitauthor 3 4 import ( 5 "github.com/goreleaser/goreleaser/internal/tmpl" 6 "github.com/goreleaser/goreleaser/pkg/config" 7 "github.com/goreleaser/goreleaser/pkg/context" 8 ) 9 10 const ( 11 defaultName = "goreleaserbot" 12 defaultEmail = "bot@goreleaser.com" 13 ) 14 15 // Get templates the commit author and returns the filled fields. 16 func Get(ctx *context.Context, og config.CommitAuthor) (config.CommitAuthor, error) { 17 var author config.CommitAuthor 18 var err error 19 20 author.Name, err = tmpl.New(ctx).Apply(og.Name) 21 if err != nil { 22 return author, err 23 } 24 author.Email, err = tmpl.New(ctx).Apply(og.Email) 25 return author, err 26 } 27 28 // Default sets the default commit author name and email. 29 func Default(og config.CommitAuthor) config.CommitAuthor { 30 if og.Name == "" { 31 og.Name = defaultName 32 } 33 if og.Email == "" { 34 og.Email = defaultEmail 35 } 36 return og 37 }