-
I just set up a pre-push hook to run my tests and I'm having some trouble. Most of the time it works, but it seems like when I do my first push to a new branch
My lefthook config is pretty simple:
Am I doing something wrong? I just want my tests to always run on a push. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I assume that you push a branch that has no changes related to the main branch, so the pre-push hook commands are being skipped. If I mistaken, please do the same thing with LEFTHOOK_VERBOSE=1 env variable set, so I could better understand what the problem is. If I am right, this feels like a confusing behavior. I will add the not to documentation. Would you like to have an option to disable implicit skips in such situation? |
Beta Was this translation helpful? Give feedback.
Thank you for the verbose logs. You are right, lefthook doesn't know what branch to use for the comparisson. For example, in case of lefthook repo I have the following output for
git branch --remotes
:In my case lefthook will use
origin/master
becauseorigin/HEAD
is pointing on it.In your case you can fix it by
git remote set-head origin main
. But this is only if your repo hasmain
as a default bra…