commitlint-rs icon indicating copy to clipboard operation
commitlint-rs copied to clipboard

git: Fix git message parsing

Open Donach opened this issue 7 months ago • 3 comments

  • Add data of Author and Date to footer

Why

I've tested the tool and decided to implement it in our company. However, there are some logical flaws which prevent us from using it. We have a policy that if a commit change is small enough, there is no need to fill in the body - the tool itself also allows to set for empty body of commit message.

However parsing of git commits with no body message creates problems. At the same time, it seems like the tool doesn't even properly split the messages, since when you use "--pretty=%B", it will return only subject+body of the commit message, so the fn extract_commit_messages will not work to separate commits properly.

By applying this fix, I was able to fix this major flaw, it also breaks no tests and no other changes are necessary.

One minor bug -> if somebody would "abuse" my usage of "|" as artificial separator, it might break the logic a bit, but IMO that is very rare case to happen.

I'm open for discussion on how to improve it further, as we don't wanna overhaul the whole tool just to fit our "few special needs".

Summary by CodeRabbit

  • New Features

    • Enhanced commit message retrieval with additional details such as author, date, and commit hash.
    • Improved parsing of commit messages to eliminate empty messages and accommodate various formatting styles.
  • Bug Fixes

    • Fixed issues with commit message extraction by refining delimiters and ensuring only valid message lines are processed.

Donach avatar Jul 25 '24 20:07 Donach