Repository: goreleaser/goreleaser
Pull request #2888 (2022-02-07 00:58:41)

fix: make --release-notes flags more deterministic
if the a file is given, but is empty, leave the changelog empty (although it will be warned).

this makes whitespace-only and empty files have the same behavior.

codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2888?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) Report
> Merging [#2888](https://codecov.io/gh/goreleaser/goreleaser/pull/2888?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) (7142f6c) into [main](https://codecov.io/gh/goreleaser/goreleaser/commit/456f8aa2b101ad414b0c94ce14ad6a836f821ace?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) (456f8aa) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/goreleaser/goreleaser/pull/2888/graphs/tree.svg?width=650&height=150&src=pr&token=3bJvv6b7hN&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)](https://codecov.io/gh/goreleaser/goreleaser/pull/2888?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)

```diff
@@           Coverage Diff           @@
##             main    #2888   +/-   ##
=======================================
  Coverage   84.51%   84.51%           
=======================================
  Files         111      111           
  Lines        8872     8872           
=======================================
  Hits         7498     7498           
  Misses       1105     1105           
  Partials      269      269           
```


| [Impacted Files](https://codecov.io/gh/goreleaser/goreleaser/pull/2888?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) | Coverage Δ | |
|---|---|---|
| [internal/pipe/changelog/changelog.go](https://codecov.io/gh/goreleaser/goreleaser/pull/2888/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser#diff-aW50ZXJuYWwvcGlwZS9jaGFuZ2Vsb2cvY2hhbmdlbG9nLmdv) | `90.66% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2888?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2888?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser). Last update [456f8aa...7142f6c](https://codecov.io/gh/goreleaser/goreleaser/pull/2888?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser).


Patch:
diff --git a/internal/pipe/changelog/changelog.go b/internal/pipe/changelog/changelog.go
index 47eccd7e..def2ad60 100644
--- a/internal/pipe/changelog/changelog.go
+++ b/internal/pipe/changelog/changelog.go
@@ -49,7 +49,7 @@ func (Pipe) Run(ctx *context.Context) error {
 	}
 	ctx.ReleaseNotes = notes
 
-	if ctx.ReleaseNotes != "" {
+	if ctx.ReleaseNotesFile != "" || ctx.ReleaseNotesTmpl != "" {
 		return nil
 	}
 
diff --git a/internal/pipe/changelog/testdata/changes-really-empty.md b/internal/pipe/changelog/testdata/changes-really-empty.md
new file mode 100644
index 00000000..e69de29b
diff --git a/www/docs/cmd/goreleaser_build.md b/www/docs/cmd/goreleaser_build.md
index 08812529..cf556bf2 100644
--- a/www/docs/cmd/goreleaser_build.md
+++ b/www/docs/cmd/goreleaser_build.md
@@ -30,6 +30,7 @@ goreleaser build [flags]
   -f, --config string      Load configuration from file
   -h, --help               help for build
       --id string          Builds only the specified build id
+  -o, --output string      Path to the binary, defaults to the distribution folder according to configs. Only taked into account when using --single-target and a single id (either with --id or if config only has one build)
   -p, --parallelism int    Amount tasks to run concurrently (default: number of CPUs)
       --rm-dist            Remove the dist folder before building
       --single-target      Builds only for current GOOS and GOARCH


Test patch:
diff --git a/internal/pipe/changelog/changelog_test.go b/internal/pipe/changelog/changelog_test.go
index 4cc090e7..886b9fa2 100644
--- a/internal/pipe/changelog/changelog_test.go
+++ b/internal/pipe/changelog/changelog_test.go
@@ -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"