Is it possible to "merge" commits in the changelog? #1069
-
My use-case is:
When I release version x+1, I actually don't want commit B to be part of the changelog since it does not make sense for users updating from x to x+1 to read about it. I achieve this by skipping "^cfix" commits. But I also use commit hashes in my changelog, so ideally I would like to have this in my changelog:
Is there any way to achieve that? I have considered not skipping the "cfix" commits but actually using a dedicated group for that, eg, "🤐 Fixes for unreleased bugs", which is probably fine too but… git-cliff is for perfectionists, isn't it? ;-) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
This is not supported currently I feel like implementing it in git-cliff itself would be fairly convoluted. Your use case is quite niche. You might be able to achieve something like it by using Tera's ability to manipulate data within the template itself: https://keats.github.io/tera/docs/#manipulating-data. But I haven't been able to come up with a solution on the fly. The overall idea would be to do a nested loop. I am thinking of something like this (not tested): body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | striptags | trim | upper_first }}
{% for commit in commits %}
{# only include non-cfix commits as their own items #}
{% if commit.message is not starting_with("cfix") %}
- {{ commit.message }} ({{commit.id}}
{# append ids of related cfix commits #}
{%- for cfix_commit in commits -%}
{%- if commit.message == cfix_commit.message -%}
, {{commit.id}}
{%- endif %-}
)
{%- endfor %}
{% endif %}
{% endfor %}
{% endfor %}\n
""" |
Beta Was this translation helpful? Give feedback.
It works!
My pyproject.toml: