fix(bump): Preserve existing changelog header when changelog_merge_prerelease is used with cz bump --changelog#1850
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1850 +/- ##
=======================================
Coverage 97.99% 97.99%
=======================================
Files 60 60
Lines 2691 2692 +1
=======================================
+ Hits 2637 2638 +1
Misses 54 54 ☔ View full report in Codecov by Sentry. |
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>
0c3bced to
778edcb
Compare
<!-- 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>
<!-- 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>
bearomorphism
left a comment
There was a problem hiding this comment.
Thanks you for reporting this issue and providing a fix! A few nits
tests/commands/test_bump_command.py
Outdated
| assert out.startswith("# Changelog\n") | ||
| assert "All notable changes to this project will be documented here." in out |
There was a problem hiding this comment.
These assertions aren't needed
There was a problem hiding this comment.
Ah, gotcha file_regression.check() is doing what I want 🙏
There was a problem hiding this comment.
confirmed with uv run pytest -k test_changelog_merge_prerelease
commitizen/commands/changelog.py
Outdated
| 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: |
There was a problem hiding this comment.
| 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.
Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
227e12e to
397abe7
Compare
Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
|
Thanks for the review @bearomorphism, this is ready for another pass. |
Description
Fixes a regression introduced in v4.11.3 (370ac9d, #1700) where using
cz bump --changelogwithchangelog_merge_prerelease = trueresults in the header of the existing changelog file being removed.Checklist
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code following the guidelines
Code Changes
uv run poe alllocally to ensure this change passes linter check and testsDocumentation Changes
uv run poe doclocally to ensure the documentation pages renders correctlyExpected Behavior
Steps to Test This Pull Request
Additional Context