I have recently migrated my SVN server to a windows server. It all went very smoothly - it was too good to be true - so it turned out.
I have/had a pre-commit hook which ran a syntax check on any PHP file committed and rejected the commit with a suitable error message if it failed the check - I will copy this below. Obviously this does not work on Windows, and I have not been able to find an alternative which does. Does anyone out there have anything?
I wouldn't really know where to start converting the below to run on a Windows system, expecially given the number of *nix tools it is reliant on :-S
I have read about pre-commit hooks which use things like Codesniffer to do the PHP checks - is something like that my best/simplest route?
#!/bin/bash
REPOS="$1"
TXN="$2"
PHP="/usr/bin/php"
SVNLOOK=/var/www/UberSVN/ubersvn/bin/svnlook
CHANGED=`$SVNLOOK changed -t "$TXN" "$REPOS" | awk '{print $2}'`
ERRORSA=0
for LINE in $CHANGED
do
FILE=`echo $LINE | egrep \\.php$`
if [ $? == 0 ]
then
MESSAGE=`$SVNLOOK cat -t "$TXN" "$REPOS" "${FILE}" | $PHP -l`
if [ $? -ne 0 ]
then
ERRORSA=1
echo "---------------------------------------------------------------------------------" 1>&2
echo "${FILE}: $MESSAGE" | sed "s| -| $FILE|g" 1>&2
fi
fi
done
if [ $ERRORSA == 1 ]
then
echo "---------------------------------------------------------------------------------" 1>&2
echo "Please correct the errors and try commit again. $ERRORSA" 1>&2
exit 1
fi
exit 0
Credit goes to my colleague to whom I passed this little problem on to, and below for any future seekers, is a pre-commit hook which will do a PHP syntax check on Windows hosted SVN servers (also checks the user has entered a commit message). Hopefully someone else will find this useful :)