Bug Description
When running commit-msg stage hooks, prek does not pass the commit message file path to the hook. The hook receives only the configured args from .pre-commit-config.yaml, but not the commit message file that git provides.
Expected Behavior
For commit-msg hooks, prek should append the commit message file path (provided by git via $1) to the hook's arguments.
Actual Behavior
The commit message file is not passed. Hooks that require the input file (like conventional-pre-commit) fail with:
error: the following arguments are required: input
Steps to Reproduce
- Create
.pre-commit-config.yaml:
repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v4.3.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args:
- --strict
- --force-scope
- Install hooks:
prek install --hook-type commit-msg
- Stage a file:
git add somefile
- Try to commit:
git commit -m "feat: test"
- Observe error:
conventional-pre-commit: error: the following arguments are required: input
Additional Context
- prek version: 0.2.19
- OS: Linux (Ubuntu)
- Calling the git hook directly works:
.git/hooks/commit-msg /tmp/test_msg.txt ✓
- During actual commits, the file is not passed
Investigation
The .git/hooks/commit-msg script runs:
exec "$PREK" hook-impl --hook-type=commit-msg --hook-dir "$HERE" -- "$@"
Git passes the commit message file as $@, but it seems prek's hook-impl doesn't forward this to the individual hooks.
Bug Description
When running
commit-msgstage hooks, prek does not pass the commit message file path to the hook. The hook receives only the configuredargsfrom.pre-commit-config.yaml, but not the commit message file that git provides.Expected Behavior
For
commit-msghooks, prek should append the commit message file path (provided by git via$1) to the hook's arguments.Actual Behavior
The commit message file is not passed. Hooks that require the input file (like
conventional-pre-commit) fail with:Steps to Reproduce
.pre-commit-config.yaml:prek install --hook-type commit-msggit add somefilegit commit -m "feat: test"conventional-pre-commit: error: the following arguments are required: inputAdditional Context
.git/hooks/commit-msg /tmp/test_msg.txt✓Investigation
The
.git/hooks/commit-msgscript runs:Git passes the commit message file as
$@, but it seems prek'shook-impldoesn't forward this to the individual hooks.