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
This commit is contained in:
Nick Nisi
2013-07-23 08:54:50 -05:00
parent 0f7a105e97
commit 4354fcc0e8
4 changed files with 82 additions and 0 deletions

22
git/templates/hooks/pre-commit Executable file
View File

@@ -0,0 +1,22 @@
#!/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}))