I\'ve recently started using git, and also begun unit testing (using Python\'s unittest
module). I\'d like to run my tests each time I commit, and only commit i
Could you parse the result of the python test session and make sure to exit your pre-commit hook with a non-zero status?
The hook should exit with non-zero status after issuing an appropriate message if it wants to stop the commit.
So if your python script does not return the appropriate status for any reason, you need to determine that status directly from the pre-commit
hook script.
That would ensure the commit does not go forward if the tests failed.
(or you could call from the hook a python wrapper which would call the tests, and ensure a sys.exit(exit_status)
according to the test results).