#!/bin/zsh
# SVN Updater
# 2010/03/04
# By Michael Stummvoll
# website: www.stummi.org
# mail: <anything here>@stummi.org
##############################################
# This script updates all your svn-repos, which are listed in ~/.svnrepos
# you have to create ~/.svnrepos before starting this script. In this file
# you should list all repos, you want to get updated automaticly. Just write
# the path of the repos, one repo per line.
# This script updates each listed repo on a run and prints out all changed 
# files (the output from 'svn update') and the commit-log from the last 
# version to the HEAD.
##############################################
# You can add a cronjob to run this script daily and mail the output to an
# email-adress you want.
# Just add a line like this in your crontab.
#
# 0 0 * * * svnupdater | mail -s "SVN STATUS" your_adress
#
# Note that you have to move or link this script to a directory, which is in your 
# $PATH variable to do so.
##############################################
# This script is under LGPL-License
##############################################

echo "-------- UPDATING SVN REPOS -------"
for i in $(cat ~/.svnrepos)
{
	echo $i
	orev=$(svnversion $i)
	svnupout=$(svn update $i)
	echo $svnupout | sed 's/^/    /'

	nrev=$(echo $svnupout | tail -n 1 | sed -e 's/[^0-9]//g')
	if [ "$orev" -ne "$nrev" ]
	then
		echo
		echo "    log:"
		svn log $i -r $(expr $orev + 1):$nrev | sed 's/^/    /'
	fi 
        echo
}

