The --changelog flag is a great feature for updating CHANGELOG.md during version bumps. However, it currently does not handle nested headings, which makes it incompatible with popular changelog formats like Keep a Changelog.
For example, given the following changelog:
## [Unreleased]
### Added
- Very Useful Feature
## [0.0.1] - 2024-11-29
### Added
- Useful Feature
After running bump minor --changelog, the result is:
## [Unreleased]
### Added
## [0.1.0] - 2024-11-29
- Very Useful Feature
## [0.0.1] - 2024-11-29
### Added
- Useful Feature
The new version (0.1.0) is inserted under the nearest heading (### Added) instead of aligning with the heading level of the previous version (##). This disrupts the structure of changelogs that use nested headings for categories (e.g., ### Added, ### Fixed, etc.).
Expected behavior:
The new version should align with the same heading level as the previous version, resulting in:
## [Unreleased]
## [0.1.0] - 2024-11-29
### Added
- Very Useful Feature
## [0.0.1] - 2024-11-29
### Added
- Useful Feature
Proposed solution
Instead of inserting the new version under the closest heading, bump should search for the previous version heading at the same level (## in this example) and insert the new version after it. This would make the --changelog flag more compatible with nested heading formats.
The
--changelogflag is a great feature for updatingCHANGELOG.mdduring version bumps. However, it currently does not handle nested headings, which makes it incompatible with popular changelog formats like Keep a Changelog.For example, given the following changelog:
After running
bump minor --changelog, the result is:The new version (
0.1.0) is inserted under the nearest heading (### Added) instead of aligning with the heading level of the previous version (##). This disrupts the structure of changelogs that use nested headings for categories (e.g.,### Added,### Fixed, etc.).Expected behavior:
The new version should align with the same heading level as the previous version, resulting in:
Proposed solution
Instead of inserting the new version under the closest heading,
bumpshould search for the previous version heading at the same level (##in this example) and insert the new version after it. This would make the--changelogflag more compatible with nested heading formats.