Skip to content

split_commits doesn't work as expected #555

@ArtemkaKun

Description

@ArtemkaKun

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

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions