fix: commit changelog even when preReleaseCommand returns false#781
Merged
fix: commit changelog even when preReleaseCommand returns false#781
Conversation
The commit decision was gated on runPreReleaseCommand()'s return value,
which returns false when:
- preReleaseCommand is explicitly empty string
- auto-bumping finds no bumpable targets (e.g. github + registry only)
This caused changelog entries to be silently lost in projects like
sentry-go that have changelog: { policy: auto } but no targets with
bumpVersion support.
The fix:
1. Explicitly `git add` the changelog file after prepareChangelog()
writes it, so it is staged regardless of preReleaseCommand outcome.
2. Replace commitNewVersion() with commitChanges() that uses `--all`
only when preReleaseCommandRan is true (version bump files could be
anywhere), and plain `git commit` otherwise (only staged files —
i.e. the changelog — get committed).
This prevents both the original bug (changelog not committed) and avoids
accidentally sweeping untracked files into the release commit.
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
The guard that checks whether the pre-release command produced changes only looked at created/modified (working tree). Since the changelog is now explicitly staged via git add before the pre-release command runs, it may appear in staged rather than modified. Include repoStatus.staged in the check to avoid a false reportError.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
The commit decision in
craft preparewas gated onrunPreReleaseCommand()'s return value. When it returnedfalse— becausepreReleaseCommandwas empty or auto-bumping found no bumpable targets — changelog changes fromprepareChangelog()were silently left uncommitted.This affected projects like sentry-go that use
changelog: { policy: auto }with onlygithub/registrytargets (neither supportsbumpVersion).Fix
Explicit changelog staging — After
prepareChangelog()writes the file, we nowgit addthe changelog path explicitly so it's staged regardless of the pre-release outcome.Conditional
--all— ReplacedcommitNewVersion()withcommitChanges()that uses--allonly whenpreReleaseCommandRanis true (version bumps can touch arbitrary files). Otherwise, plaingit commitcommits only staged files (the changelog), preventing accidental inclusion of stray working-tree artifacts.--all)--all)--all)--all)