Skip to content

Enhance --changelog to support nested headings for changelogs following Keep a Changelog format #119

@mehanoid

Description

@mehanoid

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions