Skip to content

feat(parser): allow commits to be parsed by multiple parsers - #1611

Open
ChrisJr404 wants to merge 1 commit into
orhun:mainfrom
ChrisJr404:feat/multiple-commit-parsers
Open

feat(parser): allow commits to be parsed by multiple parsers#1611
ChrisJr404 wants to merge 1 commit into
orhun:mainfrom
ChrisJr404:feat/multiple-commit-parsers

Conversation

@ChrisJr404

Copy link
Copy Markdown
Contributor

Closes #117. Adds an opt-in continue field on commit parsers so a commit can be processed by more than one parser instead of stopping at the first match.

Today the parser loop returns as soon as a commit matches a parser, so you can't have one parser set the scope and a later one set the group. The config from #117 ({ message = "(scope)", scope = "..." } followed by { message = "^feat", group = "..." }) only ever applies the first parser and the group is never set. The only workaround is spelling out every scope/group combination in a single parser, which gets tedious fast.

With this change you mark the parsers you want to compose with continue = true:

commit_parsers = [
  { message = '\(www\)', scope = "Application", continue = true },
  { message = "^feat", group = "Features" },
]

A parser with continue = true only writes the fields it actually sets (here just scope), then parsing moves on to the next parser, which fills in the group. Parsers without the flag behave exactly as before: first match wins and the loop short-circuits. So existing configs are untouched — the flag defaults to unset.

One thing worth a look: when several parsers should stack, each contributing one, they all need continue = true (a parser without it is treated as terminal and overwrites with its own fields, matching the current overwrite semantics). That felt like the least surprising reading of the issue, but I'm happy to change the shape if you had something else in mind — the thread left the design open ("needs some brainstorming").

Also handled the filtering edge case: a commit matched only by continue parsers (e.g. one that just sets a scope, no group) is kept when filter_commits is on, same as a normal match would be.

Tests in git-cliff-core/src/commit.rs (parse_commit_multiple_parsers) cover three things: the default first-match-wins path is unchanged, scope-then-group composition works with the flag, and a scope-only continue parser survives filtering. cargo test -p git-cliff-core is green (73 passed), cargo clippy --all-features clean, docs added under configuration/git.md.

Add an opt-in `continue` field to commit parsers. When set, parsing
keeps going after a parser matches, so a commit can be handled by more
than one parser in order (e.g. one sets the scope, the next sets the
group). Default behavior is unchanged: the first matching parser wins
and short-circuits.
@ChrisJr404
ChrisJr404 requested a review from orhun as a code owner August 18, 2026 05:14
@ChrisJr404

Copy link
Copy Markdown
Contributor Author

The Test suite red here isn't coming from this PR. All the tests pass; it's the codecov upload step failing on gpg signature verification (Can't check signature: No public key), the same failure that's red on main right now. Should sort itself out on a re-run.

@orhun

orhun commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Hey, thanks for the PR!

There are a couple of issues:

  1. Consider this case:

parser 1: scope = "Application", continue = true
parser 2: group = "Features", terminal

Doesscope become None because parser 2 overwrites every field? Can you confirm this?

  1. Can you add a test that matches this case? A fixture test would be also appreciated.
  2. I'd like to see some documentation update for showcasing this new feature too. We can already set scope and group in the same commit parser, so let's find another real-world use case.
  3. There seems to be some merge conflicts. Can you merge main?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow multiple parsers for skipped/non-skipped commits

2 participants