Linux Manju

October 23, 2008

SVN commit hook script

Filed under: FreeBSD, Linux — Tags: , , , , — admin @ 6:47 pm

After searching around for a while to get a decent ( Read as in not too complex and does the job its supposed to do) svn commit hook script for Automatically sending mails on each commit to a repo.

Basicallay I wanted to have infirmation about The user and the revision number in the mails along with files and folders that were modified.

So I rolled my sleeves and wrote this. Which is working beautifully for me.

vi /repo/path/hooks/post-commit

and add these lines

#!/bin/sh

REPOS=”$1″
REV=”$2″

/usr/bin/mailer.sh $1 $2
Copy the below text and paste it in /usr/bin/mailer.sh

The scripts can be downloaded from

http://linuxmanju.com//downloads/svnmailer/

( Make sure to change NOTIFY=”user@domain.com” to your own email IDs separated by a space. noreply@domain.com to your own from address )

chmod +x /usr/bin/mailer.sh

## Mailer.sh ###script

#!/bin/bash -x

#### SVN Commit Hook written By Manjunath ###
#### http://linuxmanju.com ###

NOTIFY=’user1@domain.com’
REP=$1
TMPL=/tmp/$REP-$RANDOM.txt
REVI=$2

SVNCHECK ()
{
if [ -e $TMPL ];then
rm -f $TMPL
fi
svnlook changed $REP > $TMPL
}

if [ ! -n $EMAIL ];then
unset $EMAIL
fi
SVNCHECK
export EMAIL=”SVN-Commit <dontreply@domain.com>”

mutt -s “SVN Commit on $REP Changed Revision to $REVI”  $NOTIFY < $TMPL
rm -f $TMPL

October 13, 2008

Hello world!

Filed under: Uncategorized — admin @ 7:07 pm

Hey All,

This is Manjunath working for Tejas Networks India Ltd. Based in Bangalore.

This blog is NOT a spoon feeding how to blog. Most the thigs here goes without explaination.

Regards,

Manjunath

Powered by WordPress