Skip to content

Commit

Permalink
Merge branch 'main' into windows
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Jun 17, 2023
2 parents 92efcda + 94981fb commit 9528f0c
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 35 deletions.
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ require (
golang.org/x/oauth2 v0.9.0
golang.org/x/sync v0.3.0
golang.org/x/text v0.10.0
golang.org/x/tools v0.9.3
golang.org/x/tools v0.10.0
gopkg.in/mail.v2 v2.3.1
gopkg.in/yaml.v3 v3.0.1
)
Expand Down Expand Up @@ -240,7 +240,7 @@ require (
go.opencensus.io v0.24.0 // indirect
go.uber.org/automaxprocs v1.5.2
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/mod v0.11.0 // indirect
golang.org/x/net v0.11.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/term v0.9.0 // indirect
Expand All @@ -259,3 +259,5 @@ require (
sigs.k8s.io/kind v0.17.0 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/invopop/jsonschema => github.com/caarlos0/jsonschema v0.0.0-20230614035932-131eafc78732
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,8 @@ github.com/caarlos0/go-shellwords v1.0.12 h1:HWrUnu6lGbWfrDcFiHcZiwOLzHWjjrPVehU
github.com/caarlos0/go-shellwords v1.0.12/go.mod h1:bYeeX1GrTLPl5cAMYEzdm272qdsQAZiaHgeF0KTk1Gw=
github.com/caarlos0/go-version v0.1.1 h1:1bikKHkGGVIIxqCmufhSSs3hpBScgHGacrvsi8FuIfc=
github.com/caarlos0/go-version v0.1.1/go.mod h1:Ze5Qx4TsBBi5FyrSKVg1Ibc44KGV/llAaKGp86oTwZ0=
github.com/caarlos0/jsonschema v0.0.0-20230614035932-131eafc78732 h1:Fmq8/UTqYiNUASO1gVazutjSAx+hfEb4OmovbrYpyM0=
github.com/caarlos0/jsonschema v0.0.0-20230614035932-131eafc78732/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0=
github.com/caarlos0/log v0.4.1 h1:99+ocwxvbvQPK/effsNa4Di8MA0Xt7gBQK3vY20xG18=
github.com/caarlos0/log v0.4.1/go.mod h1:Uv+r6RfrgaRmW/xoarK1S9csv+BQgS7fZbcKYXn8ggo=
github.com/caarlos0/sshmarshal v0.1.0 h1:zTCZrDORFfWh526Tsb7vCm3+Yg/SfW/Ub8aQDeosk0I=
Expand Down Expand Up @@ -1502,8 +1504,6 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/influxdata/influxdb1-client v0.0.0-20200827194710-b269163b24ab/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/intel/goresctrl v0.2.0/go.mod h1:+CZdzouYFn5EsxgqAQTEzMfwKwuc0fVdMrT9FCCAVRQ=
github.com/invopop/jsonschema v0.7.0 h1:2vgQcBz1n256N+FpX3Jq7Y17AjYt46Ig3zIWyy770So=
github.com/invopop/jsonschema v0.7.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0=
github.com/ionos-cloud/sdk-go/v6 v6.1.3/go.mod h1:Ox3W0iiEz0GHnfY9e5LmAxwklsxguuNFEUSu0gVRTME=
github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA=
github.com/j-keck/arping v1.0.2/go.mod h1:aJbELhR92bSk7tp79AWM/ftfc90EfEi2bQJrbBFOsPw=
Expand Down Expand Up @@ -2383,8 +2383,8 @@ golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI=
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -2815,8 +2815,8 @@ golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k=
golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ=
golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k=
golang.org/x/tools v0.9.3 h1:Gn1I8+64MsuTb/HpH+LmQtNas23LhUVr3rYZ0eKuaMM=
golang.org/x/tools v0.9.3/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
golang.org/x/tools v0.10.0 h1:tvDr/iQoUqNdohiYm0LmmKcBk+q86lb9EprIUFhHHGg=
golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
23 changes: 22 additions & 1 deletion internal/pipe/changelog/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,19 @@ func buildChangelog(ctx *context.Context) ([]string, error) {
}

func filterEntries(ctx *context.Context, entries []string) ([]string, error) {
for _, filter := range ctx.Config.Changelog.Filters.Exclude {
filters := ctx.Config.Changelog.Filters
if len(filters.Include) > 0 {
var newEntries []string
for _, filter := range filters.Include {
r, err := regexp.Compile(filter)
if err != nil {
return entries, err
}
newEntries = append(newEntries, keep(r, entries)...)
}
return newEntries, nil
}
for _, filter := range filters.Exclude {
r, err := regexp.Compile(filter)
if err != nil {
return entries, err
Expand Down Expand Up @@ -297,6 +309,15 @@ func sortEntries(ctx *context.Context, entries []string) []string {
return result
}

func keep(filter *regexp.Regexp, entries []string) (result []string) {
for _, entry := range entries {
if filter.MatchString(extractCommitInfo(entry)) {
result = append(result, entry)
}
}
return result
}

func remove(filter *regexp.Regexp, entries []string) (result []string) {
for _, entry := range entries {
if !filter.MatchString(extractCommitInfo(entry)) {
Expand Down
69 changes: 69 additions & 0 deletions internal/pipe/changelog/changelog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,56 @@ func TestChangelog(t *testing.T) {
require.NotEmpty(t, string(bts))
}

func TestChangelogInclude(t *testing.T) {
folder := testlib.Mktmp(t)
testlib.GitInit(t)
testlib.GitCommit(t, "first")
testlib.GitTag(t, "v0.0.1")
testlib.GitCommit(t, "added feature 1")
testlib.GitCommit(t, "fixed bug 2")
testlib.GitCommit(t, "ignored: whatever")
testlib.GitCommit(t, "docs: whatever")
testlib.GitCommit(t, "something about cArs we dont need")
testlib.GitCommit(t, "feat: added that thing")
testlib.GitCommit(t, "Merge pull request #999 from goreleaser/some-branch")
testlib.GitCommit(t, "this is not a Merge pull request")
testlib.GitTag(t, "v0.0.2")
ctx := testctx.NewWithCfg(config.Project{
Dist: folder,
Changelog: config.Changelog{
Use: "git",
Filters: config.Filters{
Include: []string{
"docs:",
"ignored:",
"(?i)cars",
"^Merge pull request",
},
},
},
}, testctx.WithCurrentTag("v0.0.2"), testctx.WithPreviousTag("v0.0.1"))
require.NoError(t, Pipe{}.Run(ctx))
require.Contains(t, ctx.ReleaseNotes, "## Changelog")
require.NotContains(t, ctx.ReleaseNotes, "first")
require.NotContains(t, ctx.ReleaseNotes, "added feature 1")
require.NotContains(t, ctx.ReleaseNotes, "fixed bug 2")
require.Contains(t, ctx.ReleaseNotes, "docs")
require.Contains(t, ctx.ReleaseNotes, "ignored")
require.Contains(t, ctx.ReleaseNotes, "cArs")
require.Contains(t, ctx.ReleaseNotes, "from goreleaser/some-branch")

for _, line := range strings.Split(ctx.ReleaseNotes, "\n")[1:] {
if line == "" {
continue
}
require.Truef(t, strings.HasPrefix(line, "* "), "%q: changelog commit must be a list item", line)
}

bts, err := os.ReadFile(filepath.Join(folder, "CHANGELOG.md"))
require.NoError(t, err)
require.NotEmpty(t, string(bts))
}

func TestChangelogForGitlab(t *testing.T) {
folder := testlib.Mktmp(t)
testlib.GitInit(t)
Expand Down Expand Up @@ -285,6 +335,25 @@ func TestChangelogFilterInvalidRegex(t *testing.T) {
require.EqualError(t, Pipe{}.Run(ctx), "error parsing regexp: invalid or unsupported Perl syntax: `(?ia`")
}

func TestChangelogFilterIncludeInvalidRegex(t *testing.T) {
testlib.Mktmp(t)
testlib.GitInit(t)
testlib.GitCommit(t, "commitssss")
testlib.GitTag(t, "v0.0.3")
testlib.GitCommit(t, "commitzzz")
testlib.GitTag(t, "v0.0.4")
ctx := testctx.NewWithCfg(config.Project{
Changelog: config.Changelog{
Filters: config.Filters{
Include: []string{
"(?iasdr4qasd)not a valid regex i guess",
},
},
},
}, testctx.WithCurrentTag("v0.0.4"), testctx.WithPreviousTag("v0.0.3"))
require.EqualError(t, Pipe{}.Run(ctx), "error parsing regexp: invalid or unsupported Perl syntax: `(?ia`")
}

func TestChangelogNoTags(t *testing.T) {
testlib.Mktmp(t)
testlib.GitInit(t)
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@ type DockerManifest struct {

// Filters config.
type Filters struct {
Include []string `yaml:"include,omitempty" json:"include,omitempty"`
Exclude []string `yaml:"exclude,omitempty" json:"exclude,omitempty"`
}

Expand Down
29 changes: 19 additions & 10 deletions www/docs/customization/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ changelog:
# This may result in an empty release notes on GitHub/GitLab/Gitea.
#
# Templates: allowed
skip: '{{ .Env.CREATE_CHANGELOG }}'
skip: "{{ .Env.CREATE_CHANGELOG }}"

# Changelog generation implementation to use.
#
Expand Down Expand Up @@ -47,8 +47,8 @@ changelog:
# Since: v1.12 (pro)
# This feature is only available in GoReleaser Pro.
paths:
- foo/
- bar/
- foo/
- bar/

# Group commits messages by given regex and title.
# Order value defines the order of the groups.
Expand All @@ -60,7 +60,7 @@ changelog:
- title: Features
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
order: 0
- title: 'Bug fixes'
- title: "Bug fixes"
regexp: '^.*?bug(\([[:word:]]+\))??!?:.+$'
order: 1
- title: Others
Expand All @@ -81,29 +81,38 @@ changelog:
# Since: v1.15 (pro)
# This feature is only available in GoReleaser Pro.
subgroups:
- title: 'Docs'
regex: '.*docs.*'
- title: "Docs"
regex: ".*docs.*"
order: 1
- title: 'CI'
regex: '.*build.*'
- title: "CI"
regex: ".*build.*"
order: 2

# Divider to use between groups.
#
# Since: v1.16 (pro)
# This feature is only available in GoReleaser Pro.
divider: '---'
divider: "---"

filters:
# Commit messages matching the regexp listed here will be removed from
# the changelog
exclude:
- '^docs:'
- "^docs:"
- typo
- (?i)foo
# Commit messages matching the regexp listed here will be the only ones
# added to the changelog
#
# If include is not-empty, exclude will be ignored.
#
# Since: v1.19
include:
- "^feat:"
```

!!! warning

Some things to keep an eye on:

* The `github-native` changelog does not support `sort` and `filter`.
Expand Down
30 changes: 22 additions & 8 deletions www/docs/static/schema-pro.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9528f0c

Please sign in to comment.