git-hooks.nix
git-hooks.nix copied to clipboard
gitlint: error on using "args"
When using the gitlint commit hook with custom arguments, then you will get an error message like:
Error: Invalid value for '--msg-filename': '-c': No such file or directory
Example
git-hooks.hooks.gitlint.args = ["-c" "general.ignore=B6" "-c" "title-max-length.line-length=120"];
Workaround
Overriding entry like:
git-hooks.hooks.gitlint.entry = "${pkgs.gitlint}/bin/gitlint -c general.ignore=B6 -c title-max-length.line-length=120 --staged --msg-filename";
@bmrips
This is mentioned in the gitlint docs:
You need to add
--msg-filenameat the end of your custom args list as the gitlint-hook will fail otherwise.
pre-commit lumps the args and filenames together *args *filenames. I'm not sure we can work around this.
The canonical way of making it easier to use hooks like this is to add options.
Yes, an option would be the best I assume.