lefthook is a popular git hook
manager. When lefthook takes over a repository's hooks it replaces the hook
scripts in .git/hooks with its own runner. Lefthook then invokes the
configured commands but, unlike git, does not forward the positional
arguments (such as the commit-message file path) to those commands.
This means that when lefthook runs mit-commit-msg and
mit-prepare-commit-msg the commit-message path argument is missing. The
hooks fall back to <gitdir>/COMMIT_EDITMSG so co-author trailers and lints
continue to work.
We need a git repository with the hooks installed.
git init .git mit-installgit mit bt seWe tell lefthook to run all three git-mit hooks. No {1} argument forwarding
is needed.
---
pre-commit:
commands:
git-mit:
run: mit-pre-commit
prepare-commit-msg:
commands:
git-mit:
run: mit-prepare-commit-msg
commit-msg:
commands:
git-mit:
run: mit-commit-msgInstalling lefthook takes over the hooks.
lefthook installWhen we commit, lefthook intercepts each hook and runs the git-mit binaries
without forwarding the commit-message path. The co-author trailers still
appear because the hooks fall back to COMMIT_EDITMSG.
echo "# Hello, world!" > README.md
git add .
git commit --message="Add a feature" --quiet
git show --pretty='format:author: [%an %ae] signed-by: [%GS]
---
%B' -qauthor: [Billie Thompson billie@example.com] signed-by: []
---
Add a feature
Co-authored-by: Someone Else <someone@example.com>