Skip to content

Feature request: Preserve version boundaries when tagged commits are filtered out #1335

@AlexandreGaubil

Description

@AlexandreGaubil

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

When using git-cliff with strict commit filtering (e.g., for a user-facing changelog), if the commit that a version tag points to gets filtered out, the entire version disappears from the changelog. This causes commits to appear under the wrong version.

Example scenario:

  • v2.14.0 tag points to commit fix(infra): update terraform config
  • My cliff-user.toml filters out (infra) scope commits (internal infrastructure changes)
  • Result: Version v2.14.0 completely disappears from the changelog, so commits that should be under v2.14.0 now appear under v2.14.1

Desired solution

I can think of two possible solutions:

Option 1: protect_tagged_commits

[git]
protect_tagged_commits = true

This would be similar to the existing protect_breaking_commits: it would prevent commits that have version tags pointing to them from being filtered out, ensuring version boundaries are preserved.

Option 2: preserve_version_boundaries

[git]
preserve_version_boundaries = true

This would ensure that git-cliff always includes all version headers in the output even if the commit with the version tag is filtered out.

Alternatives considered

I created a workaround script that:

  1. Generates context from a permissive config (all versions)
  2. Generates context from the strict config (filtered commits with groups)
  3. Merges them: takes version structure from #1, commits from #2
  4. Uses --from-context to generate the final changelog

This works but is complex and brittle. It also seems like this could be useful to other, not just me and so might be worth having in git-cliff itself.

Additional context

The configuration that causes this issue:

[git]
commit_parsers = [
    # Skip internal scopes
    { message = ".*\\((infra)\\).*", skip = true },

    # Categorize remaining
    { message = "^feat", group = "Features" },
    { message = "^fix", group = "Bug Fixes" },
]

Thanks for the great tool!

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions