Skip to content

Commit

Permalink
Merge pull request #85 from krzyzakp/enable_check_overall_files
Browse files Browse the repository at this point in the history
Enable check over all files
  • Loading branch information
krzyzakp committed Sep 23, 2016
2 parents 81d96d6 + fdd5541 commit 91bb6a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
5 changes: 4 additions & 1 deletion 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'
18 changes: 16 additions & 2 deletions pre-commit
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 91bb6a8

Please sign in to comment.