conventional-changelog / commitlint

📓 Lint commit messages

Home Page:https://commitlint.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feature request(cli): print body and footer for valid commits if “--verbose” command-line argument

Kristinita opened this issue · comments

1. Summary

It would be nice if Commitlint will print full commit, including body and footer, if commit is valid and --verbose flag is added to Commitlint command.

I think this would make adding Commitlint commands to the project clearer.

2. MCVE

2.1. Commit

git add .

git commit -m "feat(kiraexamplescope): This is a valid header" -m "This is a valid body" --signoff

2.2. Commitlint commands

npx commitlint --from=HEAD~1 --verbose

or

git log -1 --pretty=format:"%s%n%n%B" | npx commitlint --verbose

or if simple-git-hooks activated:

module.exports = {
	"commit-msg": "npx --no -- commitlint --edit \"$1\" --verbose"
};

3. Behavior

3.1. Actual

# [NOTE] I also think it would be nice to separate the word “input” with a blank line,
# because users might think it’s a name of the commit message typeinput: feat(kiraexamplescope): This is a valid header
✔   found 0 problems, 0 warnings

3.2. Expected

Input:

feat(kiraexamplescope): This is a valid header

This is a valid body

Signed-off-by: Kristinita <17247677+Kristinita@users.noreply.github.com>

✔	found 0 problems, 0 warnings

4. Explanation of the need for feature

If the commit is non-valid, Commitlint prints body and footer:

git commit -m "This is a non-valid header" -m "This is a valid body" --signoff
⧗   input: This is a non-valid header

This is a valid body

Signed-off-by: Kristinita <17247677+Kristinita@users.noreply.github.com>
✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]
✖   scope may not be empty [scope-empty]

✖   found 3 problems, 0 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

But if the commit is valid, Commitlint prints solely the header. This distinction can be confusing when user add Commitlint commands to a project. When I set up my Commitlint commands, I thought I had set up my Commitlint commands so that Commitlint parsed solely the header. I spent my time unsuccessfully trying to configure Commitlint to parse the body and footer, until I realized that Commitlint already parses the body and footer if I use the commands I provided in the “Commitlint commands” section, but for some reason it doesn’t print the full contents of the commits.

Thanks.

Hi @escapedcat I can help fixing this. It shouldn't be a breaking change right ?

Thanks @weixinwu ! Sure, give it a try. This should "only" be a new feature :)