Created
May 25, 2012 16:59
-
-
Save crazed/2789203 to your computer and use it in GitHub Desktop.
pre-commit hook for puppet syntax validation
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
#!/usr/bin/env bash | |
TEMPDIR=`mktemp -d puppet-parser.XXXXXX` | |
test -n "$TEMPDIR" || exit 1 | |
test -d "$TEMPDIR" || exit 1 | |
git checkout-index --prefix="$TEMPDIR/" -af | |
changed_manifests=$(git diff --cached --name-only --diff-filter=ACM | grep '.pp$' | xargs -n 1 -I '{}' echo $TEMPDIR/'{}' | tr '\n' ' ') | |
validate_status=0 | |
if [[ -n $changed_manifests ]]; then | |
puppet parser validate $changed_manifests | |
validate_status=$? | |
fi | |
test -d "$TEMPDIR" && rm -rf "$TEMPDIR" | |
exit $validate_status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment