Skip to content

Instantly share code, notes, and snippets.

@aussielunix
Forked from bs-github/pre-commit
Created June 30, 2012 07:32
Show Gist options
  • Save aussielunix/3022800 to your computer and use it in GitHub Desktop.
Save aussielunix/3022800 to your computer and use it in GitHub Desktop.
# Variables goes hither
declare -a FILES
IFS="
"
FILES=$(git diff --cached --name-only --diff-filter=ACM )
# I we don't have puppet-lint, so just exit and leave them be.
which puppet-lint >/dev/null 2>&1 || exit
# I we don't have puppet, so just exit and leave them be.
which puppet >/dev/null 2>&1 || exit
for file in ${FILES[@]}
do
if [[ $file =~ \.*.pp$ ]]
then
puppet-lint --fail-on-warnings --no-80chars-check --with-filename "$file"
RC=$?
if [ $RC -ne 0 ]
then
exit $RC
fi
puppet parser validate "$file"
RC=$?
if [ $RC -ne 0 ]
then
exit $RC
fi
fi
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment