Skip to content

fix(bump): Preserve existing changelog header when changelog_merge_prerelease is used with cz bump --changelog#1850

Open
edgarrmondragon wants to merge 4 commits intocommitizen-tools:masterfrom
edgarrmondragon:fix/bump-changelog-merge-pre-removes-header
Open

fix(bump): Preserve existing changelog header when changelog_merge_prerelease is used with cz bump --changelog#1850
edgarrmondragon wants to merge 4 commits intocommitizen-tools:masterfrom
edgarrmondragon:fix/bump-changelog-merge-pre-removes-header

Conversation

@edgarrmondragon
Copy link
Contributor

@edgarrmondragon edgarrmondragon commented Feb 5, 2026

Description

Fixes a regression introduced in v4.11.3 (370ac9d, #1700) where using cz bump --changelog with changelog_merge_prerelease = true results in the header of the existing changelog file being removed.

Checklist

Was generative AI tooling used to co-author this PR?

  • Yes (please specify the tool below)

Generated-by: Claude Code following the guidelines

Code Changes

  • Add test cases to all the changes you introduce
  • Run uv run poe all locally to ensure this change passes linter check and tests
  • Manually test the changes:
    • Verify the feature/bug fix works as expected in real-world scenarios
    • Test edge cases and error conditions
    • Ensure backward compatibility is maintained
    • Document any manual testing steps performed
  • Update the documentation for the changes

Documentation Changes

  • Run uv run poe doc locally to ensure the documentation pages renders correctly
  • Check and fix any broken links (internal or external)

Expected Behavior

Steps to Test This Pull Request

Additional Context

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.99%. Comparing base (2cfb8c6) to head (fb214be).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1850   +/-   ##
=======================================
  Coverage   97.99%   97.99%           
=======================================
  Files          60       60           
  Lines        2691     2693    +2     
=======================================
+ Hits         2637     2639    +2     
  Misses         54       54           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
…rerelease` is used with `cz bump --changelog`

Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
…rerelease` is used with `cz bump --changelog`, and no prereleases exist

Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
@edgarrmondragon edgarrmondragon force-pushed the fix/bump-changelog-merge-pre-removes-header branch from 0c3bced to 778edcb Compare February 5, 2026 02:12
@edgarrmondragon edgarrmondragon marked this pull request as ready for review February 5, 2026 02:17
edgarrmondragon added a commit to meltano/meltano that referenced this pull request Feb 5, 2026
<!--

Please, go through these steps when you submit a PR.

1. Make sure your branch is not protected. In particular, avoid making
PRs from the `main` branch of your fork.

2. Give a descriptive title to your PR. We use semantic titles, and the
accepted types and scopes are listed in
https://github.com/meltano/meltano/blob/main/.github/semantic.yml.

   A good title should look like this:

   ```
feat(cli): The `meltano run` command now accepts a `--timeout` option to
limit the time it runs
   ```

3. Provide a description of your changes.

4. Put "Closes #XXXX" in your comment to auto-close the issue that your
PR fixes (if such).

-->

## Description

<!-- Describe the changes introduced by this PR -->

## Related Issues

* commitizen-tools/commitizen#1850

Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
edgarrmondragon added a commit to meltano/meltano that referenced this pull request Feb 5, 2026
<!--

Please, go through these steps when you submit a PR.

1. Make sure your branch is not protected. In particular, avoid making
PRs from the `main` branch of your fork.

2. Give a descriptive title to your PR. We use semantic titles, and the
accepted types and scopes are listed in
https://github.com/meltano/meltano/blob/main/.github/semantic.yml.

   A good title should look like this:

   ```
feat(cli): The `meltano run` command now accepts a `--timeout` option to
limit the time it runs
   ```

3. Provide a description of your changes.

4. Put "Closes #XXXX" in your comment to auto-close the issue that your
PR fixes (if such).

-->

## Description

<!-- Describe the changes introduced by this PR -->

## Related Issues

* commitizen-tools/commitizen#1850

Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
Copy link
Collaborator

@bearomorphism bearomorphism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks you for reporting this issue and providing a fix! A few nits

Comment on lines +1532 to +1533
assert out.startswith("# Changelog\n")
assert "All notable changes to this project will be documented here." in out
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These assertions aren't needed

Comment on lines +1576 to +1578
assert out.startswith("# Changelog\n")
assert "All notable changes." in out
assert "## 0.1.0 (1970-01-01)" in out
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment on lines +233 to +242
has_prereleases_to_merge = latest_full_release_info.index is not None and (
latest_full_release_info.name is None
or (
changelog_meta.latest_version_position is not None
and changelog_meta.latest_version_position
< latest_full_release_info.index
)
)

if has_prereleases_to_merge and latest_full_release_info.index is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
has_prereleases_to_merge = latest_full_release_info.index is not None and (
latest_full_release_info.name is None
or (
changelog_meta.latest_version_position is not None
and changelog_meta.latest_version_position
< latest_full_release_info.index
)
)
if has_prereleases_to_merge and latest_full_release_info.index is not None:
if latest_full_release_info.index is not None and (
latest_full_release_info.name is None
or (
changelog_meta.latest_version_position is not None
and changelog_meta.latest_version_position
< latest_full_release_info.index
)
):

While has_prereleases_to_merge is descriptive, the condition latest_full_release_info.index is not None is duplicated and removing it will make mypy unhappy. The above comment is enough to help reader understand the intention behind this long expression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants