As promised, here is the follow-up to the SVN for Web Developers post, Basecamp integration.
Transparency is very important to my business. The #1 complaint I hear about web developers is that they rarely meet deadlines and the client has no idea what is happening with the work until one day it magically appears. To combat that, I use Basecamp to lay out milestones for all my projects. I’ve found that even if a project takes longer than a client would like, as long as they can count on a date that it will be delivered, they’re happy.
Milestones are usually pretty spread out and don’t give clients a good idea of what I’m doing day-to-day to meet them. Writing each Subversion commit to Basecamp gives my clients quick access to the current status of their project.
Luckily, all the hard work is done for us here. Subversion has a post commit hook to automatically run a script after a commit and a Ruby script has already been built to upload these details to Basecamp. We just have to put all the pieces in place to make it happen.
Since my experience with Subversion and Ruby are both limited, I banged my head against the wall for a while trying to get this to work. Here is my Mac-centric cookbook, but it should be trivial to port to other platforms.
1. Get the Prerequisites
wget http://basecamphq.com/api/basecamp.rb sudo mv basecamp.rb /usr/lib/ruby/1.8/ wget http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz tar xvzf rubygems-0.9.2.tgz cd rubygems-0.9.2.tgz sudo ruby setup.rb sudo gem update sudo gem install xml-simple
2. The Post Commit Script
The original script is here, but it doesn’t work out of the box. I had to change each reference of basecamp_project['project-id'] to basecamp_project['id']. I also made some additional changes to give the script prettier formatting in Basecamp and make it more portable between projects. You can download my post-commit.rb here.
To use it, you’ll need to change the constants at the top of the file to match your Basecamp setup. SHOW_CODE_CHANGES will display a list of changed files in the Basecamp message. LOG_PREPEND causes an unordered list to be built from the commit message where ever it encounters a line break followed by two hyphens.
Move it to the hooks folder of your repo and make it executable:
chmod +x post-commit.rb mv post-commit.rb /[path to svn repo]/hooks/post-commit
That’s it. Every commit automatically creates a message in Basecamp. Hope you found this helpful. I know it would have saved me a couple of hours.