Friday, January 08, 2010

Send details of SVN commit on windows using DOS/Batch script

At work we have a shared SubVersion source code repository.  At the moment we don't have a CI setup for every project and I got fed up of not always knowing that someone had also checked something in. (CI sends build/test notifications - success and failure- so I know if something has changed that way.)
So I could make sure I was always notified of when someone else had changed something in a project I'm working on I set up a post-commit hook to send me an email.

The following is a post-commit hook script that I have written to enable me to keep track of what others are checking in.  I publish it here as I couldn't find a good example of this for Windows machines.

Please note that paths and email addresses have been changed to protect the guilty. You'll want/need to change these if you use a copy of this script yourself.

rem This hook sends an email when something is checked in to this repository

set REPOS="%1"
set REV=%2

"C:\Program Files\VisualSVN Server\bin\svnlook.exe" author %REPOS% -r %REV% > D:\SUBVERSION\MISC\author%REV%.tmp

set /p AUTHOR= D:\SUBVERSION\MISC\%REV%.tmp

echo. >> D:\SUBVERSION\MISC\%REV%.tmp

echo Who: %AUTHOR% >> D:\SUBVERSION\MISC\%REV%.tmp

echo. >> D:\SUBVERSION\MISC\%REV%.tmp

echo Comment:  >> D:\SUBVERSION\MISC\%REV%.tmp
"C:\Program Files\VisualSVN Server\bin\svnlook.exe" log %REPOS% -r %REV% >> D:\SUBVERSION\MISC\%REV%.tmp

echo. >> D:\SUBVERSION\MISC\%REV%.tmp

echo Changes:  >> D:\SUBVERSION\MISC\%REV%.tmp
"C:\Program Files\VisualSVN Server\bin\svnlook.exe" changed %REPOS% -r %REV% >> D:\SUBVERSION\MISC\%REV%.tmp


D:\SUBVERSION\MISC\sendemail.exe -f svn-checkin@example.com -t name@example.com -u "Check-in for REPOSITORY-NAME" -o message-file=D:\SUBVERSION\MISC\%REV%.tmp


del D:\SUBVERSION\MISC\author%REV%.tmp
del D:\SUBVERSION\MISC\%REV%.tmp

I also use rule in outlook to ignore notifications of check-ins made by me.

This uses SendEmail by Brandon Zehm (available at: http://caspian.dotconf.net/menu/Software/SendEmail/) as a command line tool to send emails from the script.

Tuesday, January 05, 2010

Times are hard

Working with time is hard. Especially when working with multiple threads - which seem to have their own timers.
I just posted a reply to someone in Outlook 2007. Then, briefly my list of Sent Items looked like this:




It seems that even though I sent an email at what it knew was 00:00 which can (should) only ever be today something hadn't updated the date for the comparison of now and the date the messages was sent.

This is one of those issues which just looks foolish when you see it but very few people will ever see it.  It's also something that'd likely be very hard to test and unless you knew this sort of issue could occur you'd be very unlikley to look or test for it.

I guess this is merely just an observation. It's not like this would be easy particularly or worthwhile to fix.  I merely note this here so you might think about and avoid similar issues in any code you write.

Monday, January 04, 2010

A little blog post analysis

project52

If you look over at the right hand side of this blog- and probably down a bit - you'll see links to the archive of my posts.  It shows I've made a lot fewer posts last year when compared with the two previous years.  In an attempt to try and encourage myself to post a bit more and with more frequency, I've committed to taking part in Project52. 

In simple terms, the project is simply to commit to publish a new blog post each week in 2010.


Find out more at: http://project52.info/