Skip to content

Commit

Permalink
fix: make --release-notes flags more deterministic (#2888)
Browse files Browse the repository at this point in the history
* fix: make --release-notes flags more deterministic

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* chore: fmt

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
  • Loading branch information
caarlos0 committed Feb 7, 2022
1 parent 3426d04 commit 5f30f36
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
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.

0 comments on commit 5f30f36

Please sign in to comment.