mirror of
https://github.com/go-task/task.git
synced 2026-08-29 10:08:27 +02:00
feat(release): generate the GitHub release body from the changelog (#2987)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
75
cmd/release/notes_test.go
Normal file
75
cmd/release/notes_test.go
Normal file
@@ -0,0 +1,75 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/Masterminds/semver/v3"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestChangelogSection(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
const changelog = `# Changelog
|
||||
|
||||
## v3.53.1 - 2026-08-18
|
||||
|
||||
### 🚀 Features
|
||||
|
||||
- Something new (#1 by @someone).
|
||||
|
||||
### 🐛 Fixes
|
||||
|
||||
- Something fixed (#2 by @someone).
|
||||
|
||||
## v3.53.10 - 2026-08-17
|
||||
|
||||
- An entry of a version whose heading starts with "## v3.53.1".
|
||||
|
||||
## v3.5.0 - 2026-01-01
|
||||
|
||||
- An older entry.
|
||||
`
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
version string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "section with sub-headings",
|
||||
version: "3.53.1",
|
||||
expected: `### 🚀 Features
|
||||
|
||||
- Something new (#1 by @someone).
|
||||
|
||||
### 🐛 Fixes
|
||||
|
||||
- Something fixed (#2 by @someone).`,
|
||||
},
|
||||
{
|
||||
name: "last section of the file",
|
||||
version: "3.5.0",
|
||||
expected: "- An older entry.",
|
||||
},
|
||||
{
|
||||
// A patch release may ship without changelog entries.
|
||||
name: "missing section",
|
||||
version: "3.53.2",
|
||||
expected: "",
|
||||
},
|
||||
{
|
||||
name: "heading of another version starts with this one",
|
||||
version: "3.53.10",
|
||||
expected: `- An entry of a version whose heading starts with "## v3.53.1".`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
version := semver.MustParse(test.version)
|
||||
assert.Equal(t, test.expected, changelogSection(changelog, version))
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user