-
-
Notifications
You must be signed in to change notification settings - Fork 283
Feature request: Preserve version boundaries when tagged commits are filtered out #1335
Description
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.0tag points to commitfix(infra): update terraform config- My
cliff-user.tomlfilters out(infra)scope commits (internal infrastructure changes) - Result: Version
v2.14.0completely disappears from the changelog, so commits that should be underv2.14.0now appear underv2.14.1
Desired solution
I can think of two possible solutions:
Option 1: protect_tagged_commits
[git]
protect_tagged_commits = trueThis 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 = trueThis 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:
- Generates context from a permissive config (all versions)
- Generates context from the strict config (filtered commits with groups)
- Merges them: takes version structure from
#1, commits from#2 - Uses
--from-contextto 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!