My problem is quiet simple:
I'm using Husky to deal with git hooks
I have configured a prepush hooks that run 2 scripts:
"prepush": "npm-run-all --parallel lint test"
It's working correctly on single push
But when I try to push to 2 branches or more, it's not detecting failing scripts.
For an example, let say that I created 2 branches:
feature/branch-1
feature/branch-2
The husky prePush script is called but the lint script does not fail (Haven if it fail when I'm pushing only that branch).
I'm using Husky 0.14.3
You cannot run tests on a branch that you are not currently on.
If you are on feature/branch-2
and push feature/branch-1
, the githook will fire normally and run. But the current state of you application on the filesystem is feature/branch-2
, so the tests will pass.
You will need to checkout the branch you want to push, before you push.
An alternative would be to run the tests on pre-commit
instead, that way you will always be on the correct branch.
Or do some scripting that will checkout the correct branch, run the tests, push and put you back on the branch you was before. While possible, probably a bit over-engineered.