From 8d7d02f42c3947f756c18cb4d37d9d97fbd0d27d Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Wed, 10 Aug 2016 14:33:04 -0700 Subject: convert back to md --- posts/2009-04-14-git-and-prove.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 posts/2009-04-14-git-and-prove.md (limited to 'posts/2009-04-14-git-and-prove.md') diff --git a/posts/2009-04-14-git-and-prove.md b/posts/2009-04-14-git-and-prove.md new file mode 100644 index 0000000..a9f2ed9 --- /dev/null +++ b/posts/2009-04-14-git-and-prove.md @@ -0,0 +1,25 @@ +A little trick to force you to run your tests before a commit: + +in a repositorie, create the following file **.git/hooks/pre-commit** with this content: + +``` bash +#!/bin/sh +if [ -d t ]; then + res=`prove t` + if [ $? -gt 0 ]; then + echo "tests fails" + exit 1 + fi +fi +if [ -d xt ]; then + res=`prove xt` + if [ $? -gt 0 ]; then + echo "tests fails" + exit 1 + fi +fi +``` + +and don't forget to chmod with +x. + +Now, when you will do your next commit, your test suit will be executed. If the tests fails, the commit will be rejected. -- cgit v1.2.3