Skip to content

Commit 0a32d89

Browse files
committed
If this is the initial commit to the repo, all files have changed
1 parent f26a91b commit 0a32d89

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

commit_hooks/config.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
CHECK_PUPPET_LINT="enabled" # enabled, permissive or disabled (permissive runs but return code is ignored)
22
USE_PUPPET_FUTURE_PARSER="enabled" # enabled or disabled
3+
CHECK_INITIAL_COMMIT="disabled" # enabled or disabled
34
export PUPPET_LINT_OPTIONS="" # puppet-lint options to use if no rc file is present. Defaults to "--no-80chars-check"

pre-receive

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export TERM
3232
# Decide if we want the puppet future parser (already on puppet 4?)
3333
CHECK_PUPPET_LINT="enabled"
3434
USE_PUPPET_FUTURE_PARSER="enabled"
35+
CHECK_INITIAL_COMMIT="disabled"
3536
if [[ -e ${subhook_root}/config.cfg ]] ; then
3637
source "${subhook_root}/config.cfg"
3738
fi
@@ -49,7 +50,18 @@ while read -r oldrev newrev refname; do
4950
oldrev=$(git show-branch | grep '\*' | grep -v "$newrev" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//')
5051
fi
5152

52-
for changedfile in $(git diff --name-only "$oldrev" "$newrev" --diff-filter=ACM); do
53+
files_list=''
54+
if [[ "x$oldrev" == 'x' ]]; then
55+
if [[ $CHECK_INITIAL_COMMIT != "disabled" ]] ; then
56+
files_list=$(git ls-tree --full-tree -r HEAD --name-only)
57+
else
58+
echo "Skipping file checks this is the initial commit..."
59+
fi
60+
else
61+
files_list=$(git diff --name-only "$oldrev" "$newrev" --diff-filter=ACM)
62+
fi
63+
64+
for changedfile in $files_list; do
5365
tmpmodule="$tmptree/$changedfile"
5466
[[ -f "$tmpmodule" ]] || continue
5567
#check puppet manifest syntax

0 commit comments

Comments
 (0)