I'm just getting started with hooks and have met some trouble with simply running the script, as I commit with git. The script works completely as intended when ran from bash terminal with the
bash pre-commit
command. But it doesn't run at all when committing with git.
The file is located at C:/path/to/my/project/.git/hooks/pre-commit, and the content of the file is:
#!/bin/bash
cd ../
cd ../
echo "pre-commit start"
if py -m unittest discover 2>&1 | grep -q "FAILED"; then
echo "Test(s) FAILED"
exit 1
fi
echo "pre-commit end"
I have tried running the chmod command in terminal, as suggested in other posts, with no change at all.
chmod +x pre-commit