I want to add a pre-commit hook in git for windows such commit just succeed if all test pass and pylint does not return any warning. I execute those in the command line this way:
py.test
pylint mypackage
After some research I have come up with the following pre-commit bash file (only for the py.test part):
#!/bin/sh
py.test
RESULT=$?
git stash pop -q
[ $? -ne 0 ] && exit 1
[ $RESULT -ne 0 ] && exit 1
exit 0
It effectively aborts the commit and prints a No stash found
message at the end. The problem is that when I solve the failing test, the commit does not succeed and it still prints No stash found
.
How could I solve this, including also pylint checks?