mirror of
https://github.com/goreleaser/goreleaser.git
synced 2024-12-29 01:44:39 +02:00
fix: do not group changelog when using github-native (#2781)
Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
parent
04a91769c5
commit
f42e0872f6
@ -14,6 +14,7 @@ import (
|
||||
"github.com/goreleaser/goreleaser/internal/client"
|
||||
"github.com/goreleaser/goreleaser/internal/git"
|
||||
"github.com/goreleaser/goreleaser/internal/tmpl"
|
||||
"github.com/goreleaser/goreleaser/pkg/config"
|
||||
"github.com/goreleaser/goreleaser/pkg/context"
|
||||
)
|
||||
|
||||
@ -71,7 +72,7 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
"## Changelog",
|
||||
}
|
||||
|
||||
if len(ctx.Config.Changelog.Groups) > 0 {
|
||||
if shouldGroup(ctx.Config.Changelog) {
|
||||
log.Debug("grouping entries")
|
||||
groups := ctx.Config.Changelog.Groups
|
||||
|
||||
@ -124,6 +125,10 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
return os.WriteFile(path, []byte(ctx.ReleaseNotes), 0o644) //nolint: gosec
|
||||
}
|
||||
|
||||
func shouldGroup(cfg config.Changelog) bool {
|
||||
return len(cfg.Groups) > 0 && cfg.Use != "github-native"
|
||||
}
|
||||
|
||||
func getAllNonEmpty(ss []string) []string {
|
||||
var r []string
|
||||
for _, s := range ss {
|
||||
|
@ -616,3 +616,32 @@ func TestGroupBadRegex(t *testing.T) {
|
||||
ctx.Git.CurrentTag = "v0.0.2"
|
||||
require.EqualError(t, Pipe{}.Run(ctx), `failed to group into "Something": error parsing regexp: missing closing ]: `+"`"+`[(\w`+"`")
|
||||
}
|
||||
|
||||
func TestShouldGroup(t *testing.T) {
|
||||
t.Run("with groups", func(t *testing.T) {
|
||||
t.Run("github-native", func(t *testing.T) {
|
||||
require.False(t, shouldGroup(config.Changelog{
|
||||
Use: "github-native",
|
||||
Groups: []config.ChangeLogGroup{{}},
|
||||
}))
|
||||
})
|
||||
for _, u := range []string{"git", "github", "gitlab"} {
|
||||
t.Run(u, func(t *testing.T) {
|
||||
require.True(t, shouldGroup(config.Changelog{
|
||||
Use: u,
|
||||
Groups: []config.ChangeLogGroup{{}},
|
||||
}))
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("without groups", func(t *testing.T) {
|
||||
for _, u := range []string{"git", "github", "gitlab", "github-native"} {
|
||||
t.Run(u, func(t *testing.T) {
|
||||
require.False(t, shouldGroup(config.Changelog{
|
||||
Use: u,
|
||||
}))
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -744,7 +744,7 @@ type Changelog struct {
|
||||
Filters Filters `yaml:"filters,omitempty"`
|
||||
Sort string `yaml:"sort,omitempty"`
|
||||
Skip bool `yaml:"skip,omitempty"` // TODO(caarlos0): rename to Disable to match other pipes
|
||||
Use string `yaml:"use,omitempty"`
|
||||
Use string `yaml:"use,omitempty" jsonschema:"enum=git,enum=github,enum=github-native,enum=gitlab,default=git"`
|
||||
Groups []ChangeLogGroup `yaml:"groups,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ changelog:
|
||||
# - `git`: uses `git log`;
|
||||
# - `github`: uses the compare GitHub API, appending the author login to the changelog.
|
||||
# - `gitlab`: uses the compare GitLab API, appending the author name and email to the changelog.
|
||||
# - `github-native`: uses the GitHub release notes generation API.
|
||||
# - `github-native`: uses the GitHub release notes generation API, disables the groups feature.
|
||||
#
|
||||
# Defaults to `git`.
|
||||
use: github
|
||||
@ -28,6 +28,8 @@ changelog:
|
||||
# Group commits messages by given regex and title.
|
||||
# Order value defines the order of the groups.
|
||||
# Proving no regex means all commits will be grouped under the default group.
|
||||
# Groups are disabled when using github-native, as it already groups things by itself.
|
||||
#
|
||||
# Default is no groups.
|
||||
groups:
|
||||
- title: Features
|
||||
|
Loading…
Reference in New Issue
Block a user