Skip to content

Instantly share code, notes, and snippets.

@chrismay
Created March 14, 2011 16:10
Show Gist options
  • Save chrismay/869388 to your computer and use it in GitHub Desktop.
Save chrismay/869388 to your computer and use it in GitHub Desktop.
git pre-commit hook to syntax-check files
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