Svn PRE-COMMIT Hook scanning java class content Svn PRE-COMMIT Hook scanning java class content unix unix

Svn PRE-COMMIT Hook scanning java class content


This is not a full answer, but it might be enough to get you headed in the right direction. A while back I was asked to run gjslint against javascript files before allowing them to be checked into SVN. Here is the pre-hook I used for the task:

#!/bin/shSVNLOOK=/usr/bin/svnlookGJSLINT=/usr/local/bin/gjslintECHO=$(which echo)GREP=$(which grep)SED=$(which sed)## Used for Debug#MYRUNLOG=/run/svn-pre-commit/pre-commit.log#touch $MYRUNLOG#echo "" > $MYRUNLOGMYTEMPJS=/run/svn-pre-commit/temp.jstouch $MYTEMPJSecho "" > $MYTEMPJSMYTEMPLOG=/run/svn-pre-commit/gjslint.logtouch $MYTEMPLOGecho "" > $MYTEMPLOGREPOS="$1"TXN="$2"FILES_CHANGED=`$SVNLOOK changed -t$TXN $REPOS | $SED -e "s/^....//g"`LINTERROR=0for FILE in $FILES_CHANGEDdo    if $ECHO $FILE | $GREP "\.js$"    then        if ! $ECHO "$REPOS/$FILE" | $GREP "/paweb5/\|/pamc/"; then exit 0; fi        if $ECHO "$REPOS/$FILE" | $GREP "/doc/"; then exit 0; fi        if $ECHO "$REPOS/$FILE" | $GREP "/docs/"; then exit 0; fi        $SVNLOOK cat -t$TXN $REPOS $FILE > $MYTEMPJS        $ECHO "$REPO/$FILE" >> $MYTEMPLOG        $GJSLINT --strict --disable 0001 $MYTEMPJS >> $MYTEMPLOG        GJSL_ERROR_CODE=$?        if [ $GJSL_ERROR_CODE != 0 ]        then            LINTERROR=1        fi        $ECHO "~~~" >> $MYTEMPLOG    fidoneif [ $LINTERROR != 0 ]then  echo "..........................................................................." >&2  while read line; do    if $ECHO $line | $GREP "Line\|no errors\|new errors\|paweb5\|~~~"    then      echo $line >&2    fi  done < $MYTEMPLOG  echo "..........................................................................." >&2  exit 1fi# If we got here, nothing is wrong.exit 0

I believe the answer to your "BIG problem" getting the location of the working copy files might lie within $SVNLOOK cat -t$TXN $REPOS $FILE > $MYTEMPJS

If you have questions about the script feel free to ask