Skip to content

fix: keep git output out of the changelog increment file#113

Open
bearomorphism wants to merge 1 commit into
commitizen-tools:masterfrom
bearomorphism:fix/82-changelog-increment-git-output
Open

fix: keep git output out of the changelog increment file#113
bearomorphism wants to merge 1 commit into
commitizen-tools:masterfrom
bearomorphism:fix/82-changelog-increment-git-output

Conversation

@bearomorphism
Copy link
Copy Markdown

Why

When changelog_increment_filename is set, the action redirects the
bump command's stdout to that file:

�ash "${CZ_CMD[@]}" >"$INPUT_CHANGELOG_INCREMENT_FILENAME"

By default cz bump prints its post-bump git commit output to
stdout as well, so the file ends up containing not just the changelog
section but also the git noise:

## 0.21.0 (2024-05-15)

### Feat

- ...

[master abcdef] bump: version 0.20.0 -> 0.21.0
 2 files changed, 8 insertions(+), 1 deletion(-)

The user has to clean those last lines out before they can be used as
e.g. a release body, as reported in #82.

What

When changelog_increment_filename is supplied, automatically pass
--git-output-to-stderr to cz bump (unless the user already set
git_redirect_stderr: true). The git commit summary then goes to
stderr (so it still shows in the action log) and the changelog file
contains only the changelog section.

How

The fix is local to the INPUT_CHANGELOG_INCREMENT_FILENAME branch
in entrypoint.sh; behaviour is unchanged when
changelog_increment_filename is not used. Users who want the git
output in their changelog file can still get it by leaving
git_redirect_stderr at its default of false and not setting
changelog_increment_filename... which is the original use of the
flag.

Verification

Repro on a fresh test repo with one feat: commit, simulating the
relevant section of entrypoint.sh:

Before (current master) -- increment.md contents:

## 0.1.0 (2026-05-10)

### Feat

- initial

[main f21d45e] bump: version 0.0.0 -> 0.1.0
 2 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 CHANGELOG.md

After this fix -- increment.md contents:

## 0.1.0 (2026-05-10)

### Feat

- initial

The git output ([main f21d45e] ... and the file-change summary)
appears on stderr instead, so it still shows up in the workflow log
but no longer pollutes the file.

Closes #82

When `changelog_increment_filename` is set, the action redirects the
bump command's stdout to that file. Without `--git-output-to-stderr`,
the post-bump `git commit` output (e.g. `[main abcdef] bump:
version 0.0.0 -> 0.1.0` and the `2 files changed, ...` summary)
ends up appended to the changelog file, producing a noisy artifact
that has to be hand-cleaned before it can be used as a release body.

When `changelog_increment_filename` is supplied, force
`--git-output-to-stderr` unless the user already enabled it via
`git_redirect_stderr: true`. The changelog file then contains only
the actual changelog content.

Closes commitizen-tools#82

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Git output in the changelog increment file

1 participant