Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make --release-notes flags more deterministic #2888

Merged
merged 2 commits into from Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/pipe/changelog/changelog.go
Expand Up @@ -49,7 +49,7 @@ func (Pipe) Run(ctx *context.Context) error {
}
ctx.ReleaseNotes = notes

if ctx.ReleaseNotes != "" {
if ctx.ReleaseNotesFile != "" || ctx.ReleaseNotesTmpl != "" {
return nil
}

Expand Down
16 changes: 15 additions & 1 deletion internal/pipe/changelog/changelog_test.go
Expand Up @@ -25,13 +25,27 @@ func TestChangelogProvidedViaFlag(t *testing.T) {
require.Equal(t, "c0ff33 coffeee\n", ctx.ReleaseNotes)
}

func TestChangelogProvidedViaFlagIsAnWhitespaceOnlyFile(t *testing.T) {
func TestChangelogProvidedViaFlagIsAWhitespaceOnlyFile(t *testing.T) {
ctx := context.New(config.Project{})
ctx.ReleaseNotesFile = "testdata/changes-empty.md"
require.NoError(t, Pipe{}.Run(ctx))
require.Equal(t, "\n", ctx.ReleaseNotes)
}

func TestChangelogProvidedViaFlagIsReallyEmpty(t *testing.T) {
ctx := context.New(config.Project{})
ctx.ReleaseNotesFile = "testdata/changes-really-empty.md"
require.NoError(t, Pipe{}.Run(ctx))
require.Equal(t, "", ctx.ReleaseNotes)
}

func TestChangelogTmplProvidedViaFlagIsReallyEmpty(t *testing.T) {
ctx := context.New(config.Project{})
ctx.ReleaseNotesTmpl = "testdata/changes-really-empty.md"
require.NoError(t, Pipe{}.Run(ctx))
require.Equal(t, "", ctx.ReleaseNotes)
}

func TestTemplatedChangelogProvidedViaFlag(t *testing.T) {
ctx := context.New(config.Project{})
ctx.ReleaseNotesFile = "testdata/changes.md"
Expand Down
Empty file.