Created
April 4, 2014 19:04
-
-
Save solarsailer/9981131 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # 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