fix: `commitlint --last` fails
mfcollins3 opened this issue Β· comments
Steps to Reproduce
I created a valid commit message and used the npx commitlint --last --verbose
command to validate the commit message as shown here. I received the following errors:
subject may not be empty [subject-empty]
type may not be empty [type-empty]
The commit message was:
ci: validate commit messages
I added development dependencies on commitlint and husky. commitlint is
being used to validate commit messages conform to the Conventional
Commits format and follow the configured rules for the project. husky is
being used to run commitlint on every commit using the commit_msg Git
hook.
I created the setup.sh script to automate the steps to install the
project dependencies after cloning the repository.
I updated README.md with instructions on cloning the repository and
running the setup.sh
script. I created the software requirements
document to list the software that developers need to install in their
development environments in order to contribute to the product.
I created CONTRIBUTING.md with instructions on how to contribute to the
product. I added instructions on commit signing,
writing commit messages, and the workflows for bug fixes or implementing
new features.
I created the commitlint GitHub Actions workflow to run commitlint to
validate commit messages for the main branch or pull requests for the
main branch.
My configuration is:
export default {
extends: ['@commitlint/config-conventional'],
rules: {
'body-max-line-length': [1, 'always', 72],
'body-case': [1, 'always', 'sentence-case'],
'footer-max-line-length': [1, 'always', 72],
'header-max-length': [2, 'always', 52],
'scope-enum': [2, 'always', [
'android',
'api',
'flutter',
'ios'
]],
'type-enum': [2, 'always', [
'build',
'change',
'chore',
'ci',
'deprecate',
'docs',
'feat',
'fix',
'perf',
'refactor',
'remove',
'revert',
'security',
'style',
'test'
]]
}
};
Running npx commitlint --from HEAD~1 --to HEAD --verbose
succeeds.
### Current Behavior
```sh
β subject may not be empty [subject-empty]
β type may not be empty [type-empty]
β found 2 problems, 0 warnings
Expected Behavior
Commitlint should succeed and validate that the commit message is valid.
Affected packages
- cli
- core
- prompt
- config-angular
Possible Solution
No response
Context
No response
commitlint --version
@commitlint/cli@19.2.0
git --version
2.44.0
node --version
20.11.1
/cc @knocte
@mfcollins3 thanks for reporting this bug, we'll look at it on Monday.
This might still be happening:
npx commitlint --last
β§ input: "fix: f around
test
"
β subject may not be empty [subject-empty]
β type may not be empty [type-empty]
β found 2 problems, 0 warnings
β Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
npx commitlint --from HEAD~1 --to HEAD --verbose
β§ input: fix: f around
β found 0 problems, 0 warnings
@schimini can you give us access to that repo? can we fork it or...?
@knocte yes check here: https://github.com/schimini/strapi
happened basically with all my commits.
but running with the from and to flags it worked properly
@schimini
I can't run commitlint against your repo at all.
I get an error:
file:///home/ubuntu/.npm/_npx/16d437951fea4b5e/node_modules/@commitlint/cli/lib/cli.js:132
throw err;
^
Error: Cannot find module '@commitlint/types'
If I try to install @commitlint/types
, I get this:
npm ERR! code EUNSUPPORTEDPROTOCOL
npm ERR! Unsupported URL Type "workspace:": workspace:*
Node.js v18.19.1
npm v10.2.4
Ubuntu 22.04
Hmm that's weird :o
What the version you have for the cached commitliint?
my setup is:
node --version
v18.19.0
strapi % npm --version
10.2.3
strapi % npx commitlint --version
@commitlint/cli@19.2.0
npx commitlint --version
@commitlint/cli@19.5.0
@webwarrior-ws I am clueless
I tried the latest even and it ran with no problems
strapi % npx commitlint@latest --from HEAD~1 --to HEAD --verbose
Need to install the following packages:
commitlint@19.5.0
Ok to proceed? (y) y
β§ input: chore: run prettier write on clean schema attributes
β found 0 problems, 0 warnings
@schimini
Does --last
work with the latest version?
@webwarrior-ws ha ha!
It does. Disregard my comments! Sorry to waste your time.