Created
March 14, 2011 16:10
-
-
Save chrismay/869388 to your computer and use it in GitHub Desktop.
git pre-commit hook to syntax-check files
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
git diff --cached --name-status | while read st file; do | |
# skip deleted files | |
if [ "$st" == 'D' ]; then continue; fi | |
# do a check only on the puppet files | |
if [[ "$file" =~ ".pp" ]]· | |
then | |
echo "syntax checking \"$file\""· | |
if ! puppet --confdir=/tmp --vardir=/tmp --parseonly --ignoreimport "$file" | |
then | |
echo "puppet syntax check failed for file: $file" | |
exit 1 | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment