Friday, July 29, 2011

git pre-commit hook and hspec

While working on some hspec stuff, I decided to try out git's pre-commit hook and see if I can make it refuse to commit unless the unit tests pass. It was easy. Here's what I came up with:

#!/bin/sh
echo "Running specs.hs"
exec runhaskell hspec.hs --format=progress --specs specs.hs


Where specs.hs are the file with the specs for the hspec library and the --specs option tells the hspec executable to run it's own specs.

On my Mac I need to make the hook executable by running chmod +x .git/hooks/pre-commit

No comments:

Post a Comment