The first time I make such a hook ..
I need a pre-commit hook that scans all java classes for commit, it should check for any character in the class and avoid commit if some of them are found, such as characters or β , etc. I think a good way to do this dynamically changing can bring all these invalid characters to a plan file so that it can be easily changed if we need to ...
I start with a simple hook that I wrote a long time ago.
Now problem BIG gets the location of the working copy files. I have to scan the contents.
I have tried many svnlook commands, but I really cannot catch this information in a pre-commit hook ....
Getting a lot of information, but not a local file path. I use this to search for content ...
OUTPUT="$($SVNLOOK changed -t $TXN $REPOS)"
echo $SVNLOOK changed -t $TXN $REPOS 1>&2
echo "$BASEDIR" 1>&2
echo "${OUTPUT}" 1>&2
echo "$TXN $REPOS" 1>&2
Maybe this is my approach wrong?
Thank you so much!
UPDATED
Thanks to "CaffeineAddiction", you know that this is always a "BIG QUESTION" when you do something for the first time.
In fact, the real problem after all, after one day of trying was another, the SVN error related to the char client:
Error output could not be translated from the native locale to UTF-8
Now this last question has been resolved, and the script is working, you can see it below, you just need to decorate it, by the way thanks for you, I will get some ideas from you:
REPOS="$1"
TXN="$2"
SVNLOOK=/usr/bin/svnlook
OUTPUT="$($SVNLOOK changed -t $TXN $REPOS | awk '{print $2}')"
for LINE in $OUTPUT
do
FILE=`echo $LINE`
MESSAGE=`$SVNLOOK cat -t "$TXN" "$REPOS" "${FILE}"`
echo "File is: $FILE" 1>&2
echo "${MESSAGE}" > /tmp/app.txt
grep -P -n '[\x80-\xFF]' /tmp/app.txt | cut -f1 -d: 1>&2
done