Skip to content

^ in commit_parsers with split_commits not working #1093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
erikthi opened this issue Mar 13, 2025 · 4 comments
Open
1 task done

^ in commit_parsers with split_commits not working #1093

erikthi opened this issue Mar 13, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@erikthi
Copy link

erikthi commented Mar 13, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

I am trying to generate a changelog for unconventional commits. The commits may potentially contain more than one change, and I would like to use the commit parsers to grab each relevant part and make a separate entry for them in the changelog.

Steps To Reproduce

Configuration like this

{% else %}\
    ## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
    ### {{ group | striptags | trim | upper_first }}
    {% for commit in commits %}
        - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
            {% if commit.breaking %}[**breaking**] {% endif %}\
            {{ commit.message | upper_first }}\
    {% endfor %}
{% endfor %}\n
"""

footer = """
<!-- generated by git-cliff -->
"""
# remove the leading and trailing s
trim = true

[git]
conventional_commits = false
filter_unconventional = false
split_commits = true
commit_parsers = [
  { message = "^fix:", group = "Fixed" },
]
filter_commits = true
topo_order = false
sort_commits = "oldest"


cd $(mktemp -d)
git init .
git commit --allow-empty -m "Unconventional commit" -m "fix: first line of the commit body"
git cliff

This yields an empty changelog.

Expected behavior

I would the changelog to contain:

Fixed

  • Fix: first line of the commit body

This is also what happens if I change

commit_parsers = [
  { message = "^fix:", group = "Fixed" },
]

to

commit_parsers = [
  { message = "fix:", group = "Fixed" },
]

Screenshots / Logs

No response

Software information

  • Operating system: Mac OS 14.6.1
  • Rust version: 1.85.0
  • Project version: Tested on both 2.5.0 and 2.8.0

Additional context

No response

@erikthi erikthi added the bug Something isn't working label Mar 13, 2025
Copy link

welcome bot commented Mar 13, 2025

Thanks for opening your first issue at git-cliff! Be sure to follow the issue template! ⛰️

@orhun
Copy link
Owner

orhun commented Mar 14, 2025

Hello, thanks for reporting! 👋🏼

In your case, the generated commit looks like:

    Unconventional commit

    fix: first line of the commit body
  1. ^fix: won't catch this, since the message does not start with "fix"
  2. fix:: this won't also do it.
  3. You need to use .*fix to match on the whole commit message.
[git]
commit_parsers = [
  { message = ".*fix:", group = "Fixed" },
]

P.S. you can't match on specific fields of the commit since it's unconventional + conventional commit parsing is disabled (conventional_commits=false).

@orhun orhun removed their assignment Mar 14, 2025
@erikthi
Copy link
Author

erikthi commented Mar 20, 2025

But I am using split_commits, so shouldn't the "fix: first line of the commit body" be treated as one commit message, which does start with "^fix"?.

@erikthi erikthi changed the title ^ in commit_parsers with skip_lines not working ^ in commit_parsers with split_commits not working Mar 20, 2025
@orhun
Copy link
Owner

orhun commented Mar 21, 2025

Yeah I guess the problem is the ordering of the processing. This was changed in #556

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants