[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Post-commit hook recipes?

From: Peter Ruprecht <ruprech_at_jilau1.colorado.edu>
Date: Fri, 22 Jan 2010 08:42:05 -0700

> I've been looking for a collection of example post-commit hook scripts
> without much luck. If anyone knows of a good one, can you please point
> me in the right direction? If I can avoid reinventing some wheels, that
> would be great.
>
> In particular, at the moment I'm looking for a post-commit hook that
> will email *only* the user who made the previous commit.

Thanks everyone for your suggestions and input. In case it may help
someone in the future, here's a very simple post-commit bash script to
send email to the person who had committed the previous revision:

-------------------------------

#!/bin/bash

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

ADDRFILE="${REPOS}/conf/addresses"
   # format assumed to be "username name_at_someplace.com"

# find the number of the previous revision
PREVREV=`expr $REV - 1`

# find the author of the previous revision
PREVAUTHOR=`/usr/bin/svnlook author $REPOS -r $PREVREV`

# find previous author's email address
PREVADDR=`grep ^"${PREVAUTHOR} " $ADDRFILE | awk '{print $2}'`

# find files changed in current commit
CHANGED=`/usr/bin/svnlook changed $REPOS -r $REV`

# get project name
PROJ=`echo $REPOS | awk -F/ '{print $NF}'`

# mail this info to previous committer
echo "$CHANGED" | /bin/mail -s "new commit to $PROJ repository" $PREVADDR
-----------------------------
Received on 2010-01-22 16:42:41 CET

This is an archived mail posted to the Subversion Users mailing list.