Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh

REPOS="$1"
TXN="$2"
export HOME=/
SVNLOOK=/usr/bin/svnlook


# SVN pre-commit hook to check Puppet syntax for .pp files
# Modified from http://mail.madstop.com/pipermail/puppet-users/2007-March/002034.html
tmpfile=`mktemp`
$SVNLOOK changed -t "$TXN" "$REPOS" | awk '{print $2}' | grep '\.pp$' | while read line
do
    $SVNLOOK cat -t "$TXN" "$REPOS" "$line" > $tmpfile
    if [ $? -ne 0 ]
    then
        echo "Warning: Failed to checkout $line" >&2
    fi
    puppet --color=false --confdir=/tmp --vardir=/tmp --parseonly --ignoreimport $tmpfile >&2
    if [ $? -ne 0 ]
    then
        echo "Puppet syntax error in $line." >&2
        exit 2
    fi
done
res=$?
rm -f $tmpfile





# Exit if everything went well
if [ $res -ne 0 ]
then
    exit $res
fi