diff --git a/Gemfile b/Gemfile index 1afcab2..9e13b34 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,8 @@ source "https://rubygems.org" -gem 'puppet', '3.8.6' +gem 'r10k' gem 'rspec-puppet' +gem 'json_pure' +gem 'psych' +gem 'puppet', '3.8.6' gem 'puppet-lint', '2.0.0' diff --git a/pre-commit b/pre-commit index 646940a..7a1e13b 100755 --- a/pre-commit +++ b/pre-commit @@ -9,6 +9,14 @@ RC=0 hook_dir="$(dirname "$0")" hook_symlink="$(readlink "$0")" +# Manage arguments passed to script +while getopts ":a" o; do + case "${o}" in + a) + CHECK_ALL=true + esac +done + # Figure out where commit hooks are if [[ ! -z "$hook_symlink" ]] && ! [[ "$hook_symlink" == ../* ]]; then #pre-commit is setup as a symlink @@ -41,7 +49,13 @@ fi SAVEIFS=$IFS IFS=$(echo -en "\n\b") -for changedfile in $(git diff --cached --name-only --diff-filter=ACM); do +if [ $CHECK_ALL ]; then + files_to_check=$(find $git_root) +else + files_to_check=$(git diff --cached --name-only --diff-filter=ACM) +fi + +for changedfile in $files_to_check; do [[ -f "$changedfile" ]] || continue #check puppet manifest syntax if type puppet >/dev/null 2>&1; then @@ -142,7 +156,7 @@ fi #summary if [[ "$failures" -ne 0 ]]; then - echo -e "$(tput setaf 1)Error: $failures subhooks failed. Aborting commit.$(tput sgr0)" + echo -e "$(tput setaf 1)Error: $failures subhooks failed. Please fix above errors.$(tput sgr0)" exit 1 fi