-
-
Notifications
You must be signed in to change notification settings - Fork 5
Description
NOTE TO SELF: when doing git commit -v do not be committing the .lefthook.yml file as its state may be changing while doing development of this issue.
I see this as a feature request, but I feel like I'm writing it up as a bug. Opps!?!?!
Is your feature request related to a problem? Please describe.
https://github.com/evilmartians/lefthook is a tool for managing git hooks. My employer uses it to run several different programs that look at each commit for various reasons.
When lefthook runs, if it detects a file in .git/hooks that it needs to override, it will back up the file.
1934 Jun 13 14:59 pre-commit
2 Jun 13 06:56 pre-commit.old -> /opt/homebrew/bin/mit-pre-commit
In this case, the pre-commit is lefthook bash that will run everything defined in a lefthook.yml file
Of the three git hooks that git-mit uses, our lefthook only uses pre-commit
Describe the solution you'd like
I'm currently experimenting with this solution
.lefthook-local.yml
pre-commit:
commands:
git-mit:
run: /opt/homebrew/bin/mit-pre-commit
If authorship hasn't been set, this will correctly print out this error. Awesome!
Error: mit_pre_commit::errors::stale_author_error
× The details of the author of this commit are stale
╭────
1 │ 2025-06-13 13:52:01.0 -07:00:00
· ───────────────┬───────────────
· ╰── The previously set authors expired at this time
╰────
help: Can you confirm who's currently coding? It's nice to get and give
the right credit. You can fix this by running `git mit` then the
initials of whoever is coding for example: `git mit bt` or `git mit
bt se`
However, the commit message itself will not have the co-authored field.
ls -al .git/hooks
commit-msg -> /opt/homebrew/bin/mit-commit-msg
Solution 1
The following works...
cd workspace/repo
ln -s /opt/homebrew/bin/mit-prepare-commit-msg .git/hooks/prepare-commit-msg
ln -s /opt/homebrew/bin/mit-commit-msg .git/hooks/commit-msg
.lefthook-local.yml
pre-commit:
commands:
git-mit:
run: /opt/homebrew/bin/mit-pre-commit
The commit message will have authorship.
(Possible) Solution 2
I felt like this would be a more robust solution...
.lefthook-local.yml
pre-commit:
commands:
git-mit:
run: /opt/homebrew/bin/mit-pre-commit
commit-msg:
commands:
git-mit:
run: /opt/homebrew/bin/mit-commit-msg
prepare-commit-msg:
commands:
git-mit:
run: /opt/homebrew/bin/mit-prepare-commit-msg
but it results in this error:
error: the following required arguments were not provided:
<COMMIT_MESSAGE_PATH>
ls -al .git/hooks | grep mit
1934 Jun 13 15:12 commit-msg
32 Jun 13 06:56 commit-msg.old -> /opt/homebrew/bin/mit-commit-msg
1934 Jun 13 15:12 pre-commit
32 Jun 13 06:56 pre-commit.old -> /opt/homebrew/bin/mit-pre-commit
1942 Jun 13 15:12 prepare-commit-msg
40 Jun 13 15:09 prepare-commit-msg.old -> /opt/homebrew/bin/mit-prepare-commit-msg