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

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

Open
Kristinita opened this issue Dec 29, 2023 · 2 comments

Comments

@Kristinita
Copy link
Contributor

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.

@weixinwu
Copy link
Contributor

weixinwu commented Apr 13, 2024

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

@escapedcat
Copy link
Member

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

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

No branches or pull requests

3 participants