From b3953ea9dbe179a3a85e289cac66e728fa7aa8a2 Mon Sep 17 00:00:00 2001 From: jdescottes Date: Sun, 11 Aug 2013 20:07:45 +0200 Subject: [PATCH] adding precommit hook to source control --- pre-commit | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pre-commit diff --git a/pre-commit b/pre-commit new file mode 100644 index 00000000..cfa24e96 --- /dev/null +++ b/pre-commit @@ -0,0 +1,25 @@ +#!/bin/sh +# stash unstaged changes, run release task, stage release updates and restore stashed files + +NAME=$(git branch | grep '*' | sed 's/* //') + +# don't run on rebase +if [ $NAME != '(no branch)' ] +then + NOT_STAGED=$(git status | grep 'not staged') + # if [ "${NOT_STAGED#*not staged}" != "$NOT_STAGED" ] + if [ "$NOT_STAGED" != "" ] + then + echo "Unclean directory, aborting commit. Run git status." + exit 1 + fi + + grunt precommit + RETVAL=$? + + if [ $RETVAL -ne 0 ] + then + echo "grunt test failed, aborting commit. Run grunt test" + exit 1 + fi +fi \ No newline at end of file