1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-18 03:56:52 +02:00

fix: improve git info log output

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2023-09-07 18:48:40 +00:00
parent 67039edc35
commit 91fe5e40c4
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940

View File

@ -43,11 +43,25 @@ func (Pipe) Run(ctx *context.Context) error {
return err
}
ctx.Git = info
log.WithField("commit", info.Commit).WithField("latest tag", info.CurrentTag).Info("building...")
log.WithField("commit", info.Commit).
WithField("branch", info.Branch).
WithField("current_tag", info.CurrentTag).
WithField("previous_tag", firstNonEmpty(info.PreviousTag, "<unknown>")).
WithField("dirty", info.Dirty).
Info("git state")
ctx.Version = strings.TrimPrefix(ctx.Git.CurrentTag, "v")
return validate(ctx)
}
func firstNonEmpty(ss ...string) string {
for _, s := range ss {
if s != "" {
return s
}
}
return ""
}
// nolint: gochecknoglobals
var fakeInfo = context.GitInfo{
Branch: "none",
@ -151,7 +165,7 @@ func getGitInfo(ctx *context.Context) (context.GitInfo, error) {
previous, err := getPreviousTag(ctx, tag)
if err != nil {
// shouldn't error, will only affect templates
// shouldn't error, will only affect templates and changelog
log.Warnf("couldn't find any tags before %q", tag)
}