`split_commits` doesn't work as expected
ArtemkaKun opened this issue · comments
Is there an existing issue for this?
- I have searched the existing issues
Description of the bug
When I have a preprocessor, that splits commit messages into 2 commit messages with a new line - none of the commit messages appear in the changelog. When instead of a single \n
I put \n\n
- only the first commit message appears.
Steps To Reproduce
Config
[changelog]
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") %}\
\n
## {{ group | upper_first }}\
{% for group, commits in commits | group_by(attribute="scope") %}\
\n
### {{ group | upper_first }}\n\
{% for commit in commits | unique(attribute="message") %}\
\n- {{ commit.message | split(pat="\n") | first | trim }}\
{% if commit.github.username %} by @{{ commit.github.username }}{% endif %}\
{% if commit.github.pr_number %} in #{{ commit.github.pr_number }}{% endif %}\
{% endfor %}\
{% endfor %}\
{% endfor %}\
\n
## First-time contributors 🥳\n\
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}\
\n- @{{ contributor.username }} made their first contribution in #{{ contributor.pr_number }}\
{% endfor %}\
"""
trim = true
[git]
conventional_commits = true
filter_unconventional = false
split_commits = true
commit_preprocessors = [
{ pattern = '^(fix|feat|setup|doc|refactor|test|optimization)\([A-Za-z0-9_-]+\)(, (fix|feat|setup|doc|refactor|test|optimization)\([A-Za-z0-9_-]+?\))+(:\ .*)', replace = "doc(TEST): test1\ndoc(TEST): test2" },
]
commit_parsers = [
{ message = "^feat", group = "✨ Features" },
{ message = "^fix", group = "🪲 Bug Fixes" },
{ message = "^doc", group = "📚 Documentation" },
{ message = "^optimization", group = "🚀 Performance" },
{ message = "^refactor", group = "🧹 Refactor" },
{ message = "^setup", group = "⚙️ Configuration" },
{ message = "^test", group = "✅ Testing" },
]
protect_breaking_commits = false
filter_commits = false
tag_pattern = "v[0-9].*"
skip_tags = ""
ignore_tags = ""
topo_order = false
sort_commits = "oldest"
Expected behavior
Both doc(TEST): test1
and doc(TEST): test2
are visible in the Documentation
section in TEST
group.
Screenshots / Logs
No response
Software information
- Operating system: Linux
- Rust version: idk, I'm using Arch linux package https://archlinux.org/packages/extra/x86_64/git-cliff/
- Project version: git-cliff 2.1.2
Additional context
No response
For some reasons, changelog generator can't get a scope of the commits. If I set default_scope
manually - now both commits appear in the changelog
Hey, #556 should fix this. However, I'm not sure if it is a breaking change. It is quite a bit of an edge case though..
Can you pull the changes from that PR and test it out?
Okay something is definitely breaking with that PR, I will take a look
Yes, this is kind of edgecase, because our project uses modified version of conventional commits standard as a compromise between multiple developers.
That's why I want to try to preprocess "not-that-conventional-commit" message to split it on 2 conventional messages and allow changelog generator to handle it without problems.
In my head, the following order should be used:
- Preproccesing (both user and own rules)
- Filtering conventional/unconventional commits depending on parameters
- Generating changelog
However it's probably impossible to satisfy everyone, so in worst case scenario I will make a fork and apply your PR to it, so the tool can be suitable for our needs. So no worries if you can't merge it :)
I think I have found a non-breaking way to make it work in #556 - so I will just go ahead with it 🐻