Hello list,
I'm planning to deploy and use Puppet at work.
For this, I've set up a SVN server to keep track of all changes in
modules&  manifests.

Reading documentation to be able to define coding rules, I want to put
some SVN hooks to ensure for correct syntax and coding rules respect.

Does anybody here use such scripts ? Are some public version available ?
Or am I wrong going this way ?

This is mine, it does some extra syntax checking:

#!/bin/bash
# This file is managed by Puppet

export TMPDIR="/tmp/svntmp"

if [ ! -e "TMPDIR" ]; then
   mkdir -p $TMPDIR && chmod 1777 $TMPDIR
fi

export ERRCOUNT=0
export PATH="/usr/bin:/bin"
export REPOS="$1"
export TMPFILE=$(mktemp -p $TMPDIR)
export TXN="$2"

while read LINE; do
   svnlook cat -t "$TXN" "$REPOS" "$LINE" > "$TMPFILE"

   if [ $? -ne 0 ]; then
      echo "Warning: Failed to checkout $LINE" >&2
   fi

   EXT=$(echo $LINE | awk -F'.' '{ print $NF }')

   case "$EXT" in
      "erb")
         erb -x -T '-' $TMPFILE | ruby -c

         if [ $? -ne 0 ]; then
            echo "ERB parsing error in $LINE" >&2
            let ERRCOUNT+=1
         fi
      ;;
      "pp")
/usr/bin/puppet --color=false --parseonly --ignoreimport "$TMPFILE"

         if [ $? -ne 0 ]; then
            echo "Puppet syntax error in $LINE" >&2
            let ERRCOUNT+=1
         fi
      ;;
      "rb")
         ruby -c $TMPFILE

         if [ $? -ne 0 ]; then
            echo "Ruby syntax error in $LINE" >&2
            let ERRCOUNT+=1
         fi
      ;;
      "sh")
         bash -n $TMPFILE

         if [ $? -ne 0 ]; then
            echo "Bash syntax error in $LINE" >&2
            let ERRCOUNT+=1
         fi
      ;;
      *)
         continue
      ;;
   esac
done < <(svnlook changed -t "$TXN" "$REPOS" | awk '{print $2}')

rm -f "$TMPFILE"
exit $ERRCOUNT


--
Joe McDonagh
AIM: YoosingYoonickz
IRC: joe-mac on freenode
"When the going gets weird, the weird turn pro."

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to