Get in Touch with Free Air

info at facollective.com

(308) 380 5740

Git Hooks

By Robert on June 13th, 2009

Like most development shops, we use Git for source code management and campfire for internal communications with our team. We have a lot of projects going on, so it is important for us all to be aware of what the other is working on and doing.

We’ve been using a post-commit hook which notifies our campfire room whenever someone commits their work locally. It spits out the message, who wrote the code, and a timestamp. Again, nothing unusual but rather common and a best practice.

One of the annoying things of doing this is having to repeat the steps, mostly cut/paste, for each project that we want to keep in our repository. This is pretty much any project and experiment that we might be working or tinkering with - we like to keep our experiments in a repository that we can glean from later.

In the spirit of being productive, efficient and destroying any nonsensically repetitive tasks, we wrote a little gem that will create our post-commit hooks for us and populate it with the necessary details (campfire subdomain, login, password, room) and place in the .git/hooks directory of our project and then make the file executable.

We aptly named it “githooks” and it has it’s own command line tool for getting the job done - albeit it is long: githooks project_name –login login –pass password –domain domain –room “Super Duper”

With that being fairly long for the sake of flexibility, you can create a bash script that will populate the login, password, domain and room for you, so you just need to pass in the project name, e.g. campfire_hook project_name

You can find the code, it’s open source, on github, githooks. There is a read me that goes over how to use githooks and how to create the bash script I spoke of. Currently, it only supports campfire - it is all we need - but if you need something else, feel free to fork it and submit patches.

Leave your remarks