Skip to content
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

Optional unconventional commit parsing into message/body/footer #746

Open
1 task done
approximate opened this issue Jul 5, 2024 · 2 comments
Open
1 task done
Assignees
Labels
feature/request New feature or request

Comments

@approximate
Copy link

approximate commented Jul 5, 2024

Is there an existing issue or pull request for this?

  • 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_commit is set to false in 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

@approximate approximate added the feature/request New feature or request label Jul 5, 2024
Copy link

welcome bot commented Jul 5, 2024

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

@orhun
Copy link
Owner

orhun commented Sep 15, 2024

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:

But maybe we can expand this a bit and add another "unconventional" example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants