#!/bin/sh
#
# $Id: svn_maillog 452 2004-05-25 07:47:58Z sam $
# svn_maillog: send a mail log from an SVN commit
# see http://sam.zoy.org/writings/programming/svn2cvs.html for more details
#
#    (c) 2004 Sam Hocevar <sam@zoy.org>
#
#   This program is free software; you can redistribute it and/or
#   modify it under the terms of the Do What The Fuck You Want To
#   Public License as published by Banlu Kemiyatorn. See
#   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
#
#
# usage:
#   svn_maillog <SVNrepo> <SVNrev> <from@> <to@>
#
# or in your hooks/post-commit:
#   svn_maillog "$1" "$2" "svn@localhost" "sam@localhost"
#

REPOS="$1"
REV="$2"
FROM="$3"
TO="$4"

# Send mail
FILE="/tmp/svnlog-`date +%N`-$$"
svn log -v "file://$REPOS" -r "$REV" > "$FILE"
COMMITER="`sed -ne '2p' "$FILE" | cut -f3 -d' '`"
MODULE="`echo "$REPOS" | sed 's,.*/,,'`"
sed -e '/^--*$/d' "$FILE" | mail -s "$MODULE: svn commit r$REV ($COMMITER)" -a "From: $FROM" "$TO"
rm -f "$FILE"

