Closed cc-gb2 closed 2 years ago
Hi there, yes that should work pre-commit
should just forward the arguments to the underlying CLI as you said; I'll take a look at it.
Hi, there @cc-gb2 sorry for the delay, just looking into this. Just a question, could you try adding this as your args
property, please? ['--edit', './.git/COMMIT_EDITMSG', '--config', './commitlint.config.js']
I tried this but it doesn't seem to work. I notice this is on recently created respositories, such as those created by Pyscaffold although I had an error with a non-pyscaffold repository too.
I noticed in that code snippet you gave you used ./commitlint.config.js
rather than .commitlint.config.js
. With the /
it would still be searching in a default location, whereas without the /
the config is in a non-default location and so should be specified with the --config
flag.
Yeah sorry I meant to replace the config file argument with your actual path to the configuration, anyways what I think it's happening it's that somehow pre-commit
is forwarding all the arguments to the entry point of the hook.
The entry point it's commitlint --edit
(so it reads from ./.git/COMMIT_EDITMSG
by default) but when you add the args
it ends up being something like commitlint ./.git/COMMIT_EDITMSG --config ./commitlint.config.js
hence the error. My suggestion was meant to pass the correct full argument to the entry point, but as you stated it does not seem to work. I'll need to investigate further, commit-msg
hooks are a little bit trickier to debug and the pre-commit
docs aren't terribly helpful.
Hi there folks, could you try the hook with the head commit of #69 please?
Something like this:
repos:
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: fef793a347be7e7e3efb2edeb0f5970c7e8d0ce0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ["@commitlint/config-conventional"]
args: ['--config','./config-folder/commitlint.config.js']
Yep works for me, both with ./config-folder/commitlint.config.js
and .commitlint.config.js
as the target config.
Thanks for the fix!
Thank you for reporting :smile:
Hi,
I really like how this works, but I'm having an issue setting the location of the commitlint file. Ideally, I'd be able to set the commitlint config to
.commitlint.config.js
like this:which should work according to the commitlint arguments. However, I get the error
Unknown argument: .git/COMMIT_EDITMSG
.Is it possible to use
args
like shown above?