SVNStalker POC

Earlier today I was talking with a friend and mentioned that I wasn’t sure when one of my repositories had last been updated. Obviously I could have opened up my SVN client and checked the history, but it would be nicer if there was a quicker way. He recommended a Windows application that I thought was pretty cool. (And unfortunately, I forgot the name and he is offline.) It monitored SVN repos and when commits were made, a Growl-type window would appear on the desktop. The user could also quickly browse the last set of revisions as well. Seeing that I thought - I bet I could make an AIR application out of it. Here is what I came up with.

I began by doing some Googling for how to communicate with Subversion. I discovered this post by Doug McCune. Turned out he had an ActionScript library that did exactly what I wanted. Check his blog entry for details, but here is a quick example of the type of code you can use to get the latest revisions from a repository:

svnClient = new SVNClient() svnClient.addEventListener(SVNRevisionListEvent.REVISIONS_LOADED, revisionsLoadedHandler) svnClient.getLatestRevisions(svnurl, 10, true)

Pretty darn simple, right? That 3rd argument to getLatestRevisions just tells the code to get detailed information about the revision, specifically details on the files updated in the revision.

For the next part, I needed a Growl style display. Now I’m still pretty darn new at Flex and creating styled windows is something I’m not familiar with yet. Luckily Joe Rinehart has a package for this called Toast. I don’t believe he is “officially” offering it, but he gave me permission to share it in this blog post. Here is a quick example of how easy it is:

createHowl("Revision "+revision.revisionNumber,revision.comment + "\nBy "+revision.creatorName+" at " +revision.date)

Woot. Once again, simple. Most of my work was done already. So I took these packages - and some code I had created for an earlier project, and quickly wrote up a proof of concept I call SVNStalker. Upon running it, it will stay in your OSX Dock or Windows taskbar. It begins by asking you for a SVN URL, username, and password. Currently it does not support the username or password. So um, don’t use it.

After you enter a SVN url, the application will ping the server every minute. It will download the last 10 revisions and create a Growl message for each.

If you miss a Growl, or close it, you can right click in the Dock/Tray and select “View Revisions”. This opens a simple window that lets you browse the revisions in memory:

All in all, this took me maybe one hour - but again - a large majority of the work was already done. The code (my code, not the code I borrowed from Doug and Joe) is pretty damn messy. I whipped this up quick so please don’t laugh too much. This could be updated to do quite a lot more:

  • Multiple SVN repos.
  • Different Growl colors based on repo.
  • Different Growl colors based on keywords or user submitted revision. </ul> Anyway, hopefully this is useful/interesting. You can download both the source and the AIR installer below.

    Download attached file.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA https://www.raymondcamden.com

Comments