Modified: puppet/modules/subversion/manifests/init.pp
===================================================================
--- puppet/modules/subversion/manifests/init.pp 2010-11-19 00:24:22 UTC (rev 305)
+++ puppet/modules/subversion/manifests/init.pp 2010-11-19 00:46:13 UTC (rev 306)
@@ -18,16 +18,24 @@
file { $local_dir:
ensure => directory,
}
+
+ define syntax_check($regexp_ext,$check_cmd) {
+ file { "$local_dir/pre-commit.d/$name":
+ ensure => present,
+ owner => root,
+ group => root,
+ mode => 755,
+ content => template('subversion/syntax_check.sh')
+ }
+ }
+
# mettre tout les scripts dans le repertoire
-
+ syntax_check{"check_perl":
+ regexp_ext => ".p[lm]$",
+ check_cmd => "perl -c"
+ }
}
- # TODO create proper hook directory ( see zarb.org )
- # create documentation
- # - group who can commit
- # - array for who get mail on what ( hash )
- # - array of where the directory is updated
-
# later, deploy a backup file ( ie, cron job to do a dump in some directory )
# TODO
# what about pre commit ?
Added: puppet/modules/subversion/templates/syntax_check.sh
===================================================================
--- puppet/modules/subversion/templates/syntax_check.sh (rev 0)
+++ puppet/modules/subversion/templates/syntax_check.sh 2010-11-19 00:46:13 UTC (rev 306)
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+REPOS="$1"
+TXN="$2"
+
+changed=`svnlook changed -t "$TXN" "$REPOS"`
+files=`echo $changed | awk '{print $2}'`
+if echo $files | grep <%= regexp_ext %>
+then
+ svnlook cat -t "$TXN" "$REPOS" "$files" | <%= check_cmd %>
+ if [ $? -ne 0 ]
+ then
+ echo "Syntax error in $files." 1>&2
+ echo "Check it with <%= check_cmd %>"
+ exit 1
+ fi
+fi
+
+# All checks passed, so allow the commit.
+exit 0
+