Optional unconventional commit parsing into message/body/footer
Is there an existing issue or pull request for this?
- [X] I have searched the existing issues and pull requests
Feature description
Right now unconventional commits are not parsed at all: regardless of the conventional_commits value, as soon as the commit is identified as unconventional, the parsing into message, body, and footers does not happen.
However, still parsing the message might be useful in certain circumstances:
- commiter made a mistake when adding commit type (forgot, typo, etc), so this commit will never be recognized as conventional, and we can't extract its parts
-
conventional_commitis set tofalsein the config file, but we still want to filter/process e.g. footers - for unconventional commits, changelog will contain the entire commit message (possibly lots of lines), even if we only need the first line (
commit.message) and not the rest (commit.body)
I believe that having an option to enable commit message parsing for all commits, regardless of their type, solves many such problems,
I also believe that having a relatively established format convention (footers are recognized by git, and message is separated from the body by a single blank line, which is respected by git log --oneline) makes this feature not very controversial, even when conventional commit spec is not followed by the dev team, but they want to use git-cliff for changelog generation.
Last but not least, thanks a lot for a great product, your work is very much appreciated!
Desired solution
New configuration option "parse_commit_message" with possible values "always", "never", "conventional_only" (default value, compatible with current behaviour).
Whitespace characters should be trimmed from each parsed part of the commit.
Alternatives considered
Using built-in templating filters is possible in certain cases.
Additional context
No response
Thanks for opening your first issue at git-cliff! Be sure to follow the issue template! ⛰️
This is already possible, you need to set filter_unconventional to false and create appropriate commit parsers depending on your commit format for overriding different parts of the conventional commit such as group and scope. For example:
[git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = false
# filter out the commits that are not conventional
filter_unconventional = false
# regex for parsing and grouping commits
commit_parsers = [
{ message = '^fix\((.*)\)', group = 'Fix (${1})' }
]
See:
- https://git-cliff.org/docs/configuration/git#commit_parsers
But maybe we can expand this a bit and add another "unconventional" example.
It is indeed possible to parse commits and set the value of group and scope but not of message and body:
https://github.com/orhun/git-cliff/blob/729aa47797bfc073850eb24745e692244f4a6381/git-cliff-core/src/commit.rs#L365-L366
The idea is basically to not only allow matching on these fields but also allow replacing their values afterwards.
I see... well then we need new fields such as override_message, override_body, override_footer etc.
However I'm not sure how that would be useful when you can already use commit_preprocessors.