Jeff Harris Jeff Harris - 2 months ago 17
Apache Configuration Question

Apache Subversion pre-commit hook Stderror to apache's error.log

I'm running svn 1.8.10 with Apache 2.2.22 on a wheezy server. I've installed phpcs-svn-pre-commit and it's working through the pre-commit hook. All is working correctly except for the output of the pre-commit hook. When the hook passes inspection, the change is committed. When the hook fails, the change is not committed, but I get this:

$ svn -F svn-commit.tmp commit Mailer.php
Sending Mailer.php
Transmitting file data .svn: E165001: Commit failed (details follow):
svn: E165001: A repository hook failed


The errors are not being returned to the subversion client, but are being logged in the apache log file. Does anyone have a clue as to where to look to find out why stderror is going to the apache error.log instead of returned via the client?

The repository is on a remote server, not local.

== apache error.log ==

[Fri Mar 27 13:18:05 2015] [error] [client 66.79.106.82] Could not MERGE resource "/claven/svn/!svn/act/a76ca493-7302-48b3-8cff-39b0abb2bc08" into "/claven/svn/trunk/system/classes/Claven". [409, #0]
[Fri Mar 27 13:18:05 2015] [error] [client 66.79.106.82] Commit blocked by pre-commit hook (exit code 1) with output:\nExamining trunk/system/classes/Claven/Mailer.php for PHP Syntax\n\n\x1b[1mFILE: trunk/system/classes/Claven/Mailer.php\x1b[0m\n----------------------------------------------------------------------\n\x1b[1mFOUND 1 ERROR AFFECTING 1 LINE\x1b[0m\n----------------------------------------------------------------------\n 49 | \x1b[31mERROR\x1b[0m | Parameter comment must end with a full stop\n----------------------------------------------------------------------\n\nTime: 134ms; Memory: 4.75Mb\n\n [409, #165001]


== pre-commit hook ==

REPOS="$1"
TXN="$2"
PSPC=/usr/bin/scripts/phpcs-svn-pre-commit

SVNLOOK=/usr/bin/svnlook
$SVNLOOK log -t "$TXN" "$REPOS" | \
grep "[a-zA-Z0-9]" > /dev/null || exit 1


CHANGED=`$SVNLOOK changed -t "$TXN" "$REPOS" | grep "^[U|A]" | awk '{print $2}' | grep \\.php$`

for FILE in $CHANGED
do
echo "Examining $FILE for PHP Syntax" >&2
if [ $? -ne 0 ]
then
echo 1>&2
echo "***********************************" 1>&2
echo "PHP error in: $FILE:" 1>&2
echo `echo "$MESSAGE" | sed "s| -| $FILE|g"` 1>&2
echo "***********************************" 1>&2
exit 1
fi
done

"$PSPC" --extensions=php --standard=Claven --tab-width=4 -n "$REPOS" -t "$TXN" >&2 || exit 1

set -e

"$REPOS"/hooks/commit-access-control.pl "$REPOS" $TXN "$REPOS"/hooks/commit-access-control.cfg

exit 0

Answer

In my ruleset.xml, I added an argument name to hard-code a command line variable into my custom standard. Once I removed it, I received the expected output from phpcs.

I'm not sure if it was the wrong identifier or the wrong value, but removing it fixed the issue.

<!-- <arg name="colors" /> -->