-
-
Save stoyanvi/7998c652d828330d61cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SCRIPTPATH=`git rev-parse --show-toplevel`"/.git/hooks" | |
HOOKS="${SCRIPTPATH}/pre-commit-*" | |
shopt -s nullglob | |
pass=true | |
for hook in $HOOKS | |
do | |
echo "Running hook: "`basename $hook` | |
# run hook if it exists | |
if [ -f "$hook" ]; then | |
"$hook" | |
# if it returns with nonzero exit with 1 and thus abort the commit | |
if [ $? != 0 ]; then | |
echo -e "\t\033[31mFAILED\033[0m" | |
pass=false | |
else | |
echo -e "\t\033[32mSUCCEEDED\033[0m" | |
fi | |
else | |
echo "Error: file $hook not found." | |
exit 1 | |
fi | |
done | |
if ! $pass ; then | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment