git-hooks.nix icon indicating copy to clipboard operation
git-hooks.nix copied to clipboard

gitlint: error on using "args"

Open pbek opened this issue 2 months ago • 2 comments

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

pbek avatar Oct 17 '25 07:10 pbek

This is mentioned in the gitlint docs:

You need to add --msg-filename at 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.

sandydoo avatar Oct 19 '25 14:10 sandydoo

Yes, an option would be the best I assume.

pbek avatar Oct 19 '25 15:10 pbek