Files
dotfiles/git/templates/hooks/pre-commit
Nick Nisi 4354fcc0e8 Add git templates with preconfigured hooks
So far, add a single pre-commit hook which loops through the dotfiles
for *.pre-commit files and executes them
2013-07-23 08:54:50 -05:00

23 lines
401 B
Bash
Executable File

#!/bin/sh
EXIT_CODE=0
repo=$( git rev-parse --show-toplevel )
HOOKS=~/.dotfiles/git/hooks
echo "Executing PRE-COMMIT hook(s)"
for hook in $HOOKS/*.pre-commit; do
echo ""
echo "${COLOR_LIGHTPURPLE}Executing ${hook}${COLOR_NONE}"
${hook}
EXIT_CODE=$((${EXIT_CODE} + $?))
done
if [[ ${EXIT_CODE} -ne 0 ]]; then
echo ""
echo "${COLOR_RED}Commit Failed.${COLOR_NONE}"
fi
exit $((${EXIT_CODE}))