#!/bin/bash # taken from http://ten-fingers-and-a-brain.com/2012/01/subversion-post-commit-hook-e-mail-report-script-that-sends-the-diff-as-an-attachment/ FROMADDRESS="svn@`hostname --fqdn`" USAGE="Usage: `basename $0` -d PATH -mailto MAILTO\n\nCreates a commit report and sends it via E-mail\n\nValid options:\n\n\t-d PATH : specify repository path PATH (required)\n\t-mailto MAILTO : specify report recipients MAILTO,\n\t comma-separated (required)\n\t-rev ARG : specify repository revision ARG, defaults to\n\t youngest revision\n\t-name ARG : specify repository nice name ARG, defaults to\n\t basename of PATH\n\n" if [ $# -eq 0 ] then echo -e >&2 "$USAGE"; exit 3; fi REPO="" MAILTO="" REV="" NAME="" while [ $# -gt 0 ] do case "$1" in -d) REPO="$2"; shift;; -mailto) MAILTO="$2"; shift;; -rev) REV="$2"; shift;; -name) NAME="$2"; shift;; *) echo -e >&2 "$USAGE"; exit 3;; esac if [ $# -eq 0 ] then echo >&2 "`basename $0`: missing argument"; exit 3; fi shift done if [ -z $REPO ] then echo >&2 "`basename $0`: missing required option -d"; exit 3; fi if [ -z $MAILTO ] then echo >&2 "`basename $0`: missing required option -mailto"; exit 3; fi if [ -z $REV ] then REV=`svnlook youngest $REPO` fi FILENAME=`basename $REPO` if [ -z $NAME ] then NAME="SVN: $FILENAME" fi LOG=`svnlook log $REPO -r $REV` LOG1=`svnlook log $REPO -r $REV | head -n1` CHANGED=`svnlook changed $REPO -r $REV` AUTHOR=`svnlook author $REPO -r $REV` REVDATE=`svnlook date $REPO -r $REV` BOUNDARY=_`date | md5sum | cut -d\ -f1`_ /usr/sbin/sendmail -f $FROMADDRESS -t <
Revision
$REV
Author
$AUTHOR
Commit Date
$REVDATE

Log Message

$LOG

Changes

$CHANGED
--_002$BOUNDARY-- --_001$BOUNDARY Content-Type: application/octet-stream Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="$FILENAME-$REV.diff.gz" `svnlook diff $REPO -r $REV | gzip | base64` --_001$BOUNDARY-- EOF