1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

fix: improve changelog a bit (#3673)

revert a bit of the changes made in #3668 to improve mergeability with
pro.

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2022-12-29 14:07:23 -03:00 committed by GitHub
parent c714e13a84
commit bd98343e4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -375,10 +375,13 @@ type changeloger interface {
type gitChangeloger struct{}
var validSHA1 = regexp.MustCompile(`^[a-fA-F0-9]{40}$`)
func (g gitChangeloger) Log(ctx *context.Context) (string, error) {
args := []string{"log", "--pretty=oneline", "--abbrev-commit", "--no-decorate", "--no-color"}
if ctx.Git.PreviousTag == "" {
args = append(args, ctx.Git.FirstCommit, ctx.Git.CurrentTag)
prev, current := comparePair(ctx)
if validSHA1.MatchString(prev) {
args = append(args, prev, current)
} else {
args = append(args, fmt.Sprintf("tags/%s..tags/%s", ctx.Git.PreviousTag, ctx.Git.CurrentTag))
}
@ -391,10 +394,8 @@ type scmChangeloger struct {
}
func (c *scmChangeloger) Log(ctx *context.Context) (string, error) {
if ctx.Git.PreviousTag == "" {
return c.client.Changelog(ctx, c.repo, ctx.Git.FirstCommit, ctx.Git.PreviousTag)
}
return c.client.Changelog(ctx, c.repo, ctx.Git.PreviousTag, ctx.Git.PreviousTag)
prev, current := comparePair(ctx)
return c.client.Changelog(ctx, c.repo, prev, current)
}
type githubNativeChangeloger struct {
@ -405,3 +406,12 @@ type githubNativeChangeloger struct {
func (c *githubNativeChangeloger) Log(ctx *context.Context) (string, error) {
return c.client.GenerateReleaseNotes(ctx, c.repo, ctx.Git.PreviousTag, ctx.Git.CurrentTag)
}
func comparePair(ctx *context.Context) (prev string, current string) {
prev = ctx.Git.PreviousTag
current = ctx.Git.CurrentTag
if prev == "" {
prev = ctx.Git.FirstCommit
}
return
}