Created
June 3, 2013 18:01
-
-
Save logicminds/5700014 to your computer and use it in GitHub Desktop.
This is my git pre commit hook that would work for linux and windows systems
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 | |
against=$1 | |
FILES=`git diff --cached --name-only --diff-filter=ACM` | |
# validate json files | |
for file in $FILES | |
do | |
# validate json files | |
if [[ $file == *.json ]]; then | |
echo "Validating json file: $file" | |
python -m json.tool $file > /dev/null | |
# validate puppet manifests | |
elif [[ $file == *.pp ]]; then | |
echo "Validating puppet file: $file" | |
puppet parser validate $file | |
fi | |
# if any validation failed display error | |
if [[ $? != 0 ]]; then | |
exit 1 | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment