Compare commits

..

No commits in common. "b0c50518b3c324d88cb4d1a1c3403c60a3fb83f8" and "93bb42e7815f08657ccc29a38040ecdaf62f82b2" have entirely different histories.

17 changed files with 124 additions and 263 deletions

View file

@ -43,17 +43,17 @@ The release pull request description has text fields where maintainers can add t
When you edit the description, make sure to put your desired content into the code blocks named `rp-prefix` and `rp-suffix`. Only the content of these blocks is considered.
> ~~~~rp-prefix
> ```rp-prefix
> ### Prefix
>
> This will be shown as the Prefix.
> ~~~~
> ```
>
> ~~~~rp-suffix
> ```rp-suffix
> ### Suffix
>
> This will be shown as the Suffix.
> ~~~~
> ```
To match the style of the auto-generated release notes, you should start any headings at level 3 (`### Title`).

View file

@ -30,17 +30,17 @@ Any text in code blocks with these languages is being added to the start or end
**Examples**:
~~~~rp-prefix
```rp-prefix
#### Awesome new feature!
This text is at the start of the release notes.
~~~~
```
~~~~rp-suffix
```rp-suffix
#### Version Compatibility
And this at the end.
~~~~
```
### Status

View file

@ -3,9 +3,9 @@ package changelog
import (
"bytes"
_ "embed"
"html/template"
"log"
"log/slog"
"text/template"
"github.com/apricote/releaser-pleaser/internal/commitparser"
"github.com/apricote/releaser-pleaser/internal/markdown"

View file

@ -8,7 +8,6 @@ import (
"github.com/apricote/releaser-pleaser/internal/commitparser"
"github.com/apricote/releaser-pleaser/internal/git"
"github.com/apricote/releaser-pleaser/internal/testdata"
)
func ptr[T any](input T) *T {
@ -144,9 +143,16 @@ func Test_NewChangelogEntry(t *testing.T) {
},
version: "1.0.0",
link: "https://example.com/1.0.0",
prefix: testdata.MustReadFileString(t, "prefix.txt"),
prefix: "### Breaking Changes",
},
want: testdata.MustReadFileString(t, "changelog-entry-prefix.txt"),
want: `## [1.0.0](https://example.com/1.0.0)
### Breaking Changes
### Bug Fixes
- Foobar!
`,
wantErr: assert.NoError,
},
{
@ -161,9 +167,18 @@ func Test_NewChangelogEntry(t *testing.T) {
},
version: "1.0.0",
link: "https://example.com/1.0.0",
suffix: testdata.MustReadFileString(t, "suffix.txt"),
suffix: "### Compatibility\n\nThis version is compatible with flux-compensator v2.2 - v2.9.",
},
want: testdata.MustReadFileString(t, "changelog-entry-suffix.txt"),
want: `## [1.0.0](https://example.com/1.0.0)
### Bug Fixes
- Foobar!
### Compatibility
This version is compatible with flux-compensator v2.2 - v2.9.
`,
wantErr: assert.NoError,
},
}

View file

@ -15,18 +15,18 @@ If you want to modify the proposed release, add you overrides here. You can lear
This will be added to the start of the release notes.
~~~~rp-prefix
```rp-prefix
{{- if .Overrides.Prefix }}
{{ .Overrides.Prefix }}{{ end }}
~~~~
```
### Suffix / End
This will be added to the end of the release notes.
~~~~rp-suffix
```rp-suffix
{{- if .Overrides.Suffix }}
{{ .Overrides.Suffix }}{{ end }}
~~~~
```
</details>

View file

@ -6,7 +6,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/apricote/releaser-pleaser/internal/git"
"github.com/apricote/releaser-pleaser/internal/testdata"
"github.com/apricote/releaser-pleaser/internal/versioning"
)
@ -38,24 +37,20 @@ func TestReleasePullRequest_GetOverrides(t *testing.T) {
name: "prefix in description",
pr: ReleasePullRequest{
PullRequest: git.PullRequest{
Description: testdata.MustReadFileString(t, "description-prefix.txt"),
Description: "```rp-prefix\n## Foo\n\n- Cool thing\n```",
},
},
want: ReleaseOverrides{
Prefix: testdata.MustReadFileString(t, "prefix.txt"),
},
want: ReleaseOverrides{Prefix: "## Foo\n\n- Cool thing"},
wantErr: assert.NoError,
},
{
name: "suffix in description",
pr: ReleasePullRequest{
PullRequest: git.PullRequest{
Description: testdata.MustReadFileString(t, "description-suffix.txt"),
Description: "```rp-suffix\n## Compatibility\n\nNo compatibility guarantees.\n```",
},
},
want: ReleaseOverrides{
Suffix: testdata.MustReadFileString(t, "suffix.txt"),
},
want: ReleaseOverrides{Suffix: "## Compatibility\n\nNo compatibility guarantees."},
wantErr: assert.NoError,
},
}
@ -85,10 +80,30 @@ func TestReleasePullRequest_ChangelogText(t *testing.T) {
wantErr: assert.NoError,
},
{
name: "with section",
description: testdata.MustReadFileString(t, "changelog.txt"),
want: testdata.MustReadFileString(t, "changelog-content.txt"),
wantErr: assert.NoError,
name: "with section",
description: `# Foobar
<!-- section-start changelog -->
This is the changelog
## Awesome
### New
#### Changes
<!-- section-end changelog -->
Suffix Things
`,
want: `This is the changelog
## Awesome
### New
#### Changes
`,
wantErr: assert.NoError,
},
}
for _, tt := range tests {
@ -163,17 +178,75 @@ func TestReleasePullRequest_SetDescription(t *testing.T) {
name: "no overrides",
changelogEntry: `## v1.0.0`,
overrides: ReleaseOverrides{},
want: testdata.MustReadFileString(t, "description-no-overrides.txt"),
wantErr: assert.NoError,
want: `<!-- section-start changelog -->
## v1.0.0
<!-- section-end changelog -->
---
<details>
<summary><h4>PR by <a href="https://github.com/apricote/releaser-pleaser">releaser-pleaser</a> 🤖</h4></summary>
If you want to modify the proposed release, add you overrides here. You can learn more about the options in the docs.
## Release Notes
### Prefix / Start
This will be added to the start of the release notes.
` + "```" + `rp-prefix
` + "```" + `
### Suffix / End
This will be added to the end of the release notes.
` + "```" + `rp-suffix
` + "```" + `
</details>
`,
wantErr: assert.NoError,
},
{
name: "existing overrides",
changelogEntry: `## v1.0.0`,
overrides: ReleaseOverrides{
Prefix: testdata.MustReadFileString(t, "prefix.txt"),
Suffix: testdata.MustReadFileString(t, "suffix.txt"),
Prefix: "This release is awesome!",
Suffix: "Fooo",
},
want: testdata.MustReadFileString(t, "description-overrides.txt"),
want: `<!-- section-start changelog -->
## v1.0.0
<!-- section-end changelog -->
---
<details>
<summary><h4>PR by <a href="https://github.com/apricote/releaser-pleaser">releaser-pleaser</a> 🤖</h4></summary>
If you want to modify the proposed release, add you overrides here. You can learn more about the options in the docs.
## Release Notes
### Prefix / Start
This will be added to the start of the release notes.
` + "```" + `rp-prefix
This release is awesome!
` + "```" + `
### Suffix / End
This will be added to the end of the release notes.
` + "```" + `rp-suffix
Fooo
` + "```" + `
</details>
`,
wantErr: assert.NoError,
},
}

View file

@ -1,7 +0,0 @@
This is the changelog
## Awesome
### New
#### Changes

View file

@ -1,19 +0,0 @@
## [1.0.0](https://example.com/1.0.0)
## Foo
- Cool thing
```go
// Some code example
func IsPositive(number int) error {
if number < 0 {
return fmt.Errorf("number %d is negative", number)
}
return nil
}
```
### Bug Fixes
- Foobar!

View file

@ -1,9 +0,0 @@
## [1.0.0](https://example.com/1.0.0)
### Bug Fixes
- Foobar!
## Compatibility
This version is compatible with flux-compensator v2.2 - v2.9.

View file

@ -1,13 +0,0 @@
# Foobar
<!-- section-start changelog -->
This is the changelog
## Awesome
### New
#### Changes
<!-- section-end changelog -->
Suffix Things

View file

@ -1,28 +0,0 @@
<!-- section-start changelog -->
## v1.0.0
<!-- section-end changelog -->
---
<details>
<summary><h4>PR by <a href="https://github.com/apricote/releaser-pleaser">releaser-pleaser</a> 🤖</h4></summary>
If you want to modify the proposed release, add you overrides here. You can learn more about the options in the docs.
## Release Notes
### Prefix / Start
This will be added to the start of the release notes.
~~~~rp-prefix
~~~~
### Suffix / End
This will be added to the end of the release notes.
~~~~rp-suffix
~~~~
</details>

View file

@ -1,44 +0,0 @@
<!-- section-start changelog -->
## v1.0.0
<!-- section-end changelog -->
---
<details>
<summary><h4>PR by <a href="https://github.com/apricote/releaser-pleaser">releaser-pleaser</a> 🤖</h4></summary>
If you want to modify the proposed release, add you overrides here. You can learn more about the options in the docs.
## Release Notes
### Prefix / Start
This will be added to the start of the release notes.
~~~~rp-prefix
## Foo
- Cool thing
```go
// Some code example
func IsPositive(number int) error {
if number < 0 {
return fmt.Errorf("number %d is negative", number)
}
return nil
}
```
~~~~
### Suffix / End
This will be added to the end of the release notes.
~~~~rp-suffix
## Compatibility
This version is compatible with flux-compensator v2.2 - v2.9.
~~~~
</details>

View file

@ -1,41 +0,0 @@
<!-- section-start changelog -->
## v1.0.0
<!-- section-end changelog -->
---
<details>
<summary><h4>PR by <a href="https://github.com/apricote/releaser-pleaser">releaser-pleaser</a> 🤖</h4></summary>
If you want to modify the proposed release, add you overrides here. You can learn more about the options in the docs.
## Release Notes
### Prefix / Start
This will be added to the start of the release notes.
~~~~rp-prefix
## Foo
- Cool thing
```go
// Some code example
func IsPositive(number int) error {
if number < 0 {
return fmt.Errorf("number %d is negative", number)
}
return nil
}
```
~~~~
### Suffix / End
This will be added to the end of the release notes.
~~~~rp-suffix
~~~~
</details>

View file

@ -1,31 +0,0 @@
<!-- section-start changelog -->
## v1.0.0
<!-- section-end changelog -->
---
<details>
<summary><h4>PR by <a href="https://github.com/apricote/releaser-pleaser">releaser-pleaser</a> 🤖</h4></summary>
If you want to modify the proposed release, add you overrides here. You can learn more about the options in the docs.
## Release Notes
### Prefix / Start
This will be added to the start of the release notes.
~~~~rp-prefix
~~~~
### Suffix / End
This will be added to the end of the release notes.
~~~~rp-suffix
## Compatibility
This version is compatible with flux-compensator v2.2 - v2.9.
~~~~
</details>

View file

@ -1,13 +0,0 @@
## Foo
- Cool thing
```go
// Some code example
func IsPositive(number int) error {
if number < 0 {
return fmt.Errorf("number %d is negative", number)
}
return nil
}
```

View file

@ -1,3 +0,0 @@
## Compatibility
This version is compatible with flux-compensator v2.2 - v2.9.

View file

@ -1,19 +0,0 @@
package testdata
import (
"embed"
"testing"
)
//go:embed *.txt
var testdata embed.FS
func MustReadFileString(t *testing.T, name string) string {
t.Helper()
content, err := testdata.ReadFile(name)
if err != nil {
t.Fatal(err)
}
return string(content)
}