Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions commit_hooks/config.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CHECK_PUPPET_LINT="enabled" # enabled, permissive or disabled (permissive runs but return code is ignored)
USE_PUPPET_FUTURE_PARSER="enabled" # enabled or disabled
CHECK_INITIAL_COMMIT="disabled" # enabled or disabled
export PUPPET_LINT_OPTIONS="" # puppet-lint options to use if no rc file is present. Defaults to "--no-80chars-check"
14 changes: 13 additions & 1 deletion pre-receive
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export TERM
# Decide if we want the puppet future parser (already on puppet 4?)
CHECK_PUPPET_LINT="enabled"
USE_PUPPET_FUTURE_PARSER="enabled"
CHECK_INITIAL_COMMIT="disabled"
if [[ -e ${subhook_root}/config.cfg ]] ; then
source "${subhook_root}/config.cfg"
fi
Expand All @@ -49,7 +50,18 @@ while read -r oldrev newrev refname; do
oldrev=$(git show-branch | grep '\*' | grep -v "$newrev" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//')
fi

for changedfile in $(git diff --name-only "$oldrev" "$newrev" --diff-filter=ACM); do
files_list=''
if [[ "x$oldrev" == 'x' ]]; then
if [[ $CHECK_INITIAL_COMMIT != "disabled" ]] ; then
files_list=$(git ls-tree --full-tree -r HEAD --name-only)
else
echo "Skipping file checks this is the initial commit..."
fi
else
files_list=$(git diff --name-only "$oldrev" "$newrev" --diff-filter=ACM)
fi

for changedfile in $files_list; do
tmpmodule="$tmptree/$changedfile"
[[ -f "$tmpmodule" ]] || continue
#check puppet manifest syntax
Expand Down