commitlint ignores commit messages starting with hashtag "#"
See original GitHub issueExpected Behavior
commitlint -e
fails when type is not present and a hashtag is used at the beginning of the commit message
Current Behavior
commitlint -e
succeeds when omitting a type and using a hashtag at the beginning of the commit message
Affected packages
- cli
- core
- prompt
- config-angular
Possible Solution
Is a #
maybe interpeted as a comment, and thus succeeds?
Steps to Reproduce (for bugs)
We have a .husky/pre-commit
file with the following contents
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
commitlint -e
Our .commitlintrc.json
looks like this
{
"extends": ["./node_modules/@commitlint/config-conventional"],
"rules": {
"subject-case": [0],
"type-enum": [2, "always", ["feat", "fix", "chore"]],
"header-max-length": [0, "always", 120],
"body-max-line-length": [0, "always", "Infinity"],
"footer-max-line-length": [0, "always", "Infinity"]
}
}
Using this configuration, writing in CLI
git commit -m "foo: bar"
leads to
$ commitlint -e
⧗ input: foo: bar
✖ type must be one of [feat, fix, chore] [type-enum]
✖ found 1 problems, 0 warnings
ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
husky - commit-msg hook exited with code 1 (error)
while git commit -m "#8299-fix-prettier"
leads to
Done in 0.58s.
[feature/test 66676512] #8299-fix-prettier
1 file changed, 111 insertions(+)
create mode 100644 test.yml
My suspicion is that it’s somehow interpeted as comment? But shouldn’t it still fail, since we have the always rule case regarding the type.
Context
We are using azure devops, so in order to link workitems (tickets) to a commit, we used the commit message template #1234 Add foo
before. We now switched to conventional commits and have a pre-commit hook.
However, some developers still need to adjust to these changes and accidentally commit with the wrong commit message. This shouldn’t be a problem, since we have pre-commit hooks, however the pre-commit hook is not triggered when using a hashtag as a commit message
Your Environment
Executable | Version |
---|---|
commitlint --version |
13.1.0 |
git --version |
2.32.0.windows.1 |
node --version |
v14.17.3 |
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top GitHub Comments
Yes, makes sense! You also state that in the README.md so no worries! We now updated to v17.0.1 Thanks for this library and the quick support
I just confirmed, when using 17.0.1 this issue is resolved. Commiting with a message as described now leads to an error
Since my bug was for an
EOL
version, I will close this issue as it is resolved and won’t be fixed. We updated our package to version 17.0.1