Booko’s Blogo

All about Booko

Fun with git post-commit

with one comment

While developing new features or bug fixes Booko, I usually work in branches. This makes keeping things separate easy, and means I can easily keep the current production version clean and easy to find.  But when changing branches I often have to restart the rails server and the price grabber to pickup any changes.  For example, if I’m adding a new shop in a branch, when I switch branches I want the price grabber to restart.

Turns out git makes this super easy. You just create a shell script: .git/hooks/post-checkout

That script gets called after checkout. So, mine is pretty simple:

#!/bin/sh

./bin/fetch_price.rb 0 restart;
thin restart

There’s probably a better way to get Thin to reload itself, but this works nicely.

You can checkout all the hooks here: http://www.kernel.org/pub/software/scm/git/docs/v1.5.5.4/hooks.html

Written by Dan Milne

October 24th, 2009 at 3:15 pm

Posted in Development,Ruby

One Response to 'Fun with git post-commit'

Subscribe to comments with RSS or TrackBack to 'Fun with git post-commit'.

  1. [...] Over on the Booko Blog. [...]

Leave a Reply