You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The option to skip some hooks does not work correctly for pre-push hooks. The check to determine if a branch is in merge state only works for pre-commit hooks.
One of the ways to check the state correctly for pre-push hooks is e.g. $(git log -1 --pretty=%P | wc -w) -gt 1.
Lefthook version
v1.7.15
Steps to reproduce
Have a pre-push hook that should be skipped for merge and rebase
Because of skip: merge, the hook should be skipped
Actual results
The hook is not skipped.
Possible Solution
Instead of checking the presence of .git/MERGE_HEAD, in case of a pre-push hook, lefthook should check if the last commit was a merge commit or not. E.g. via $(git log -1 --pretty=%P | wc -w) -gt 1 in bash
The text was updated successfully, but these errors were encountered:
I will add a separate skip option merge-commit so you can use it instead of merge. I think this is more useful than supporting different behavior depending on the git hook name.
🔧 Summary
The option to skip some hooks does not work correctly for
pre-push
hooks.The check to determine if a branch is in merge state only works for
pre-commit
hooks.One of the ways to check the state correctly for
pre-push
hooks is e.g.$(git log -1 --pretty=%P | wc -w) -gt 1
.Lefthook version
v1.7.15
Steps to reproduce
pre-push
hook that should be skipped formerge
andrebase
branch-x
git merge master
Expected results
Because of
skip: merge
, the hook should be skippedActual results
The hook is not skipped.
Possible Solution
Instead of checking the presence of
.git/MERGE_HEAD
, in case of a pre-push hook, lefthook should check if the last commit was a merge commit or not. E.g. via$(git log -1 --pretty=%P | wc -w) -gt 1
in bashThe text was updated successfully, but these errors were encountered: