mirror of
https://github.com/apricote/releaser-pleaser.git
synced 2026-01-13 13:21:00 +00:00
fix: using code blocks within release-notes
Increase the number of code blocks backticks to 4 for the release note prefix and suffix, to allow users to embed their own code blocks using only 3 backticks.
This commit is contained in:
parent
93bb42e781
commit
7f25b3bf92
13 changed files with 229 additions and 103 deletions
|
|
@ -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`).
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ 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"
|
||||
)
|
||||
|
||||
|
|
@ -37,20 +38,24 @@ func TestReleasePullRequest_GetOverrides(t *testing.T) {
|
|||
name: "prefix in description",
|
||||
pr: ReleasePullRequest{
|
||||
PullRequest: git.PullRequest{
|
||||
Description: "```rp-prefix\n## Foo\n\n- Cool thing\n```",
|
||||
Description: testdata.MustReadFileString(t, "description-prefix.txt"),
|
||||
},
|
||||
},
|
||||
want: ReleaseOverrides{Prefix: "## Foo\n\n- Cool thing"},
|
||||
want: ReleaseOverrides{
|
||||
Prefix: testdata.MustReadFileString(t, "prefix.txt"),
|
||||
},
|
||||
wantErr: assert.NoError,
|
||||
},
|
||||
{
|
||||
name: "suffix in description",
|
||||
pr: ReleasePullRequest{
|
||||
PullRequest: git.PullRequest{
|
||||
Description: "```rp-suffix\n## Compatibility\n\nNo compatibility guarantees.\n```",
|
||||
Description: testdata.MustReadFileString(t, "description-suffix.txt"),
|
||||
},
|
||||
},
|
||||
want: ReleaseOverrides{Suffix: "## Compatibility\n\nNo compatibility guarantees."},
|
||||
want: ReleaseOverrides{
|
||||
Suffix: testdata.MustReadFileString(t, "suffix.txt"),
|
||||
},
|
||||
wantErr: assert.NoError,
|
||||
},
|
||||
}
|
||||
|
|
@ -80,30 +85,10 @@ func TestReleasePullRequest_ChangelogText(t *testing.T) {
|
|||
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,
|
||||
name: "with section",
|
||||
description: testdata.MustReadFileString(t, "changelog.txt"),
|
||||
want: testdata.MustReadFileString(t, "changelog-content.txt"),
|
||||
wantErr: assert.NoError,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
|
@ -178,75 +163,17 @@ func TestReleasePullRequest_SetDescription(t *testing.T) {
|
|||
name: "no overrides",
|
||||
changelogEntry: `## v1.0.0`,
|
||||
overrides: ReleaseOverrides{},
|
||||
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,
|
||||
want: testdata.MustReadFileString(t, "description-no-overrides.txt"),
|
||||
wantErr: assert.NoError,
|
||||
},
|
||||
{
|
||||
name: "existing overrides",
|
||||
changelogEntry: `## v1.0.0`,
|
||||
overrides: ReleaseOverrides{
|
||||
Prefix: "This release is awesome!",
|
||||
Suffix: "Fooo",
|
||||
Prefix: testdata.MustReadFileString(t, "prefix.txt"),
|
||||
Suffix: testdata.MustReadFileString(t, "suffix.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>
|
||||
`,
|
||||
want: testdata.MustReadFileString(t, "description-overrides.txt"),
|
||||
wantErr: assert.NoError,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
7
internal/testdata/changelog-content.txt
vendored
Normal file
7
internal/testdata/changelog-content.txt
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
This is the changelog
|
||||
|
||||
## Awesome
|
||||
|
||||
### New
|
||||
|
||||
#### Changes
|
||||
13
internal/testdata/changelog.txt
vendored
Normal file
13
internal/testdata/changelog.txt
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Foobar
|
||||
|
||||
<!-- section-start changelog -->
|
||||
This is the changelog
|
||||
|
||||
## Awesome
|
||||
|
||||
### New
|
||||
|
||||
#### Changes
|
||||
<!-- section-end changelog -->
|
||||
|
||||
Suffix Things
|
||||
28
internal/testdata/description-no-overrides.txt
vendored
Normal file
28
internal/testdata/description-no-overrides.txt
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<!-- 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>
|
||||
44
internal/testdata/description-overrides.txt
vendored
Normal file
44
internal/testdata/description-overrides.txt
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<!-- 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
|
||||
|
||||
No compatibility guarantees.
|
||||
~~~~
|
||||
|
||||
</details>
|
||||
41
internal/testdata/description-prefix.txt
vendored
Normal file
41
internal/testdata/description-prefix.txt
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<!-- 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>
|
||||
31
internal/testdata/description-suffix.txt
vendored
Normal file
31
internal/testdata/description-suffix.txt
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<!-- 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
|
||||
|
||||
No compatibility guarantees.
|
||||
~~~~
|
||||
|
||||
</details>
|
||||
13
internal/testdata/prefix.txt
vendored
Normal file
13
internal/testdata/prefix.txt
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
## 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
|
||||
}
|
||||
```
|
||||
3
internal/testdata/suffix.txt
vendored
Normal file
3
internal/testdata/suffix.txt
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
## Compatibility
|
||||
|
||||
No compatibility guarantees.
|
||||
19
internal/testdata/testdata.go
vendored
Normal file
19
internal/testdata/testdata.go
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue