Skip to content

Instantly share code, notes, and snippets.

@solarsailer
Created April 4, 2014 19:04
Show Gist options
  • Save solarsailer/9981131 to your computer and use it in GitHub Desktop.
Save solarsailer/9981131 to your computer and use it in GitHub Desktop.
# To create a pre-commit hook:
# cd .git/ && mkdir hooks && cd hooks && touch pre-commit && chmod +x pre-commit
# -------------------------------------------------------
# PUPPET-LINT
# -------------------------------------------------------
#!/bin/bash
# Requires bash, as it uses the [[ ]] syntax.
#
# If it's puppet code, lint it up.
# I we don't have puppet-lint, so just exit and leave them be.
which puppet-lint >/dev/null 2>&1 || exit
# Variables goes hither
declare -a FILES
IFS="
"
FILES=$(git diff --cached --name-only --diff-filter=ACM )
for file in ${FILES[@]}
do
if [[ $file =~ \.*.pp$ ]]
then
puppet-lint --with-filename "$file"
RC=$?
if [ $RC -ne 0 ]
then
exit $RC
fi
fi
done
exit 0
# -------------------------------------------------------
# Rest.
# -------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment