You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-11-06 09:09:29 +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:
committed by
GitHub
parent
04a91769c5
commit
f42e0872f6
@@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/goreleaser/goreleaser/internal/client"
|
"github.com/goreleaser/goreleaser/internal/client"
|
||||||
"github.com/goreleaser/goreleaser/internal/git"
|
"github.com/goreleaser/goreleaser/internal/git"
|
||||||
"github.com/goreleaser/goreleaser/internal/tmpl"
|
"github.com/goreleaser/goreleaser/internal/tmpl"
|
||||||
|
"github.com/goreleaser/goreleaser/pkg/config"
|
||||||
"github.com/goreleaser/goreleaser/pkg/context"
|
"github.com/goreleaser/goreleaser/pkg/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ func (Pipe) Run(ctx *context.Context) error {
|
|||||||
"## Changelog",
|
"## Changelog",
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(ctx.Config.Changelog.Groups) > 0 {
|
if shouldGroup(ctx.Config.Changelog) {
|
||||||
log.Debug("grouping entries")
|
log.Debug("grouping entries")
|
||||||
groups := ctx.Config.Changelog.Groups
|
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
|
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 {
|
func getAllNonEmpty(ss []string) []string {
|
||||||
var r []string
|
var r []string
|
||||||
for _, s := range ss {
|
for _, s := range ss {
|
||||||
|
|||||||
@@ -616,3 +616,32 @@ func TestGroupBadRegex(t *testing.T) {
|
|||||||
ctx.Git.CurrentTag = "v0.0.2"
|
ctx.Git.CurrentTag = "v0.0.2"
|
||||||
require.EqualError(t, Pipe{}.Run(ctx), `failed to group into "Something": error parsing regexp: missing closing ]: `+"`"+`[(\w`+"`")
|
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"`
|
Filters Filters `yaml:"filters,omitempty"`
|
||||||
Sort string `yaml:"sort,omitempty"`
|
Sort string `yaml:"sort,omitempty"`
|
||||||
Skip bool `yaml:"skip,omitempty"` // TODO(caarlos0): rename to Disable to match other pipes
|
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"`
|
Groups []ChangeLogGroup `yaml:"groups,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ changelog:
|
|||||||
# - `git`: uses `git log`;
|
# - `git`: uses `git log`;
|
||||||
# - `github`: uses the compare GitHub API, appending the author login to the changelog.
|
# - `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.
|
# - `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`.
|
# Defaults to `git`.
|
||||||
use: github
|
use: github
|
||||||
@@ -28,6 +28,8 @@ changelog:
|
|||||||
# Group commits messages by given regex and title.
|
# Group commits messages by given regex and title.
|
||||||
# Order value defines the order of the groups.
|
# Order value defines the order of the groups.
|
||||||
# Proving no regex means all commits will be grouped under the default group.
|
# 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.
|
# Default is no groups.
|
||||||
groups:
|
groups:
|
||||||
- title: Features
|
- title: Features
|
||||||
|
|||||||
Reference in New Issue
Block a user