cwilper

Navigation

Recent site activity

post-commit script

#!/bin/sh

# Usage  : post-commit /path/to/svnroot revision-number
# Purpose: On svn commit, send email notification to the
#          appropriate project's codewatch mailing list.

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

# All codewatch messages come from this user
# Note: This user must be allowed to send to each list
FROM=codewatch@yourhost.yourdomain

# Provides the ViewVC link to the changelog in the repository
URL="http://yourhost.yourdomain/svn/view?view=rev&revision=%s"

# Get the first top-level directory changed by the commit
# Note: svnlook's dirs-changed output is multi-line, and
#       each line looks like "projname/trunk/etc"
PROJ=`/usr/bin/svnlook dirs-changed -r $REV $REPOS|head -1|sed -e 's/\/.*//g'`

# Decide which list to send to
case "$PROJ" in
  proj1)
        TO=proj1-codewatch@googlegroups.com
        REPLY=proj1-dev@googlegroups.com
        ;;
  proj2)
        TO=proj2-codewatch@googlegroups.com
        REPLY=proj2-dev@googlegroups.com
        ;;
  *)
        echo 1>&2 "WARNING: Email notification not configured for $PROJ"
        exit 1
esac

# The project has been configured above, so send the notification
/usr/bin/svnnotify --revision $REV --with-diff --repos-path $REPOS --revision-url $URL --subject-prefix r --to $TO --from $FROM --reply-to $REPLY
exit $?