Monday, November 8, 2010

SVN post-commit hook

Never was able to run the mailer.py script included with subversion...

I use the perl SVN::Notify package. The post-commit hook looks like this:


#!/bin/sh


REPOS="$1"
REV="$2"

DIRCHANGED="`/usr/bin/svnlook dirs-changed -r $REV $REPOS | head -1`"
MODULE="`echo $DIRCHANGED | awk -F\/ '{print $1}'`"
if [ "$MODULE" == "module-with-sub-modules" ]; then
  MODULE=$MODULE/"`echo $DIRCHANGED | awk -F\/ '{print $2}'`"
fi


NOTIFY=""
if [ "$MODULE" != "module-with-sub-modules/" ]; then
  NOTIFY="`grep $MODULE $REPOS/hooks/notify-address-map | head -1 | awk -F: '{print $2}'`"
fi

if [ "$NOTIFY" == "" ]; then
  NOTIFY="nobody"
else
svnnotify --repos-path "$REPOS" --revision "$REV" --to "$NOTIFY" --subject-prefix "[GRPM]" --svnlook /usr/bin/svnlook  --viewcvs-url "https://oncoweb.chuq.qc.ca/websvn/revision.php?rev=%s" -C --with-diff  --handler HTML::ColorDiff
fi

Then, notify-address-map looks like:

G4Common:pdespres@somewhere,another@somewhereelse
CurieMC:you@know,the@rest

No comments: