Skip to content

Commit 98ecc9f

Browse files
committed
Merge pull request #66 from smbambling/f_pre_receive_r10k
Add r10k pre-receive hook
2 parents 3d27960 + f26a91b commit 98ecc9f

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

commit_hooks/r10k_syntax_check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# This script assumes you have installed r10k and will perform a syntax check on the Puppetfile if existing
44

55
echo "Performing a syntax check on the r10k Puppetfile:"
6-
r10k puppetfile check
6+
PUPPETFILE="$1" r10k puppetfile check
77

88
if [[ $? -ne 0 ]]
99
then

pre-commit

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ done
115115
IFS=$SAVEIFS
116116

117117
#rspec test validation
118-
if which rspec >/dev/null 2>&1; then
118+
if hash rspec >/dev/null 2>&1; then
119119
${subhook_root}/rspec_puppet_checks.sh
120120
RC=$?
121121
if [[ "$RC" -ne 0 ]]; then
@@ -126,7 +126,7 @@ else
126126
fi
127127

128128
#r10k puppetfile syntax check
129-
if which r10k >/dev/null 2>&1; then
129+
if hash r10k >/dev/null 2>&1; then
130130
if [[ "$changedfile" = "Puppetfile" ]]; then
131131
"${subhook_root}/r10k_syntax_check.sh"
132132
RC=$?

pre-receive

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ while read -r oldrev newrev refname; do
129129
echo "puppet-lint not installed. Skipping puppet-lint tests..."
130130
fi
131131
fi
132+
#r10k puppetfile syntax check
133+
if hash r10k >/dev/null 2>&1; then
134+
if [ "$changedfile" = "Puppetfile" ]; then
135+
${subhook_root}/r10k_syntax_check.sh $tmptree/$changedfile
136+
RC=$?
137+
if [ "$RC" -ne 0 ]; then
138+
failures=`expr $failures + 1`
139+
fi
140+
fi
141+
else
142+
echo "r10k not installed. Skipping r10k Puppetfile test..."
143+
fi
132144
done
133145
done
134146
rm -rf "$tmptree"

0 commit comments

Comments
 (0)