I am trying to build a pre-commit script in SVN, and I want to run PHP_CodeSniffer on the modified lines only (as opposed to the whole file). So far I have this script:
#!/bin/sh
REPOS="$1"
TXN="$2"
# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
$SVNLOOK log -t "$TXN" "$REPOS" | \
grep "[a-zA-Z0-9]" > /dev/null || exit 1
# Check for code validation before commiting the script using PHP_CodeSniffer
/tmp/pear/download/PHP_CodeSniffer-1.4.3/scripts/phpcs-svn-pre-commit "$REPOS" -t "$TXN" >&2 || exit 1
# All checks passed, so allow the commit.
exit 0