Skip to content

Commit

Permalink
Merge pull request #71 from jcpunk/initial-commit
Browse files Browse the repository at this point in the history
If this is the initial commit to the repo, all files have changed
  • Loading branch information
drwahl committed Mar 23, 2016
2 parents 8e36cd0 + 0a32d89 commit 0735b05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
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

0 comments on commit 0735b05

Please sign in to comment.