]> git.donarmstrong.com Git - dsa-puppet.git/commitdiff
Update pre-commit hook
authorStephen Gran <steve@lobefin.net>
Wed, 25 Apr 2012 07:02:01 +0000 (08:02 +0100)
committerStephen Gran <steve@lobefin.net>
Wed, 25 Apr 2012 07:02:01 +0000 (08:02 +0100)
Now will update itself and reexec itself if it has changes, and is
better at catching syntax errors in manifests

Signed-off-by: Stephen Gran <steve@lobefin.net>
tools/git-hooks/pre-commit

index 23e6e6aa2f4b7061ad1e2c5937e08a8643ff822f..9d70e36c11dff6e124a5d9cfcb381a30cc540543 100755 (executable)
@@ -1,5 +1,11 @@
 #!/bin/bash
 
+if ! cmp -s ${PWD}/.git/hooks/pre-commit ${PWD}/tools/git-hooks/pre-commit ; then
+       rm -f ${PWD}/.git/hooks/pre-commit
+       ln -sf ../../tools/git-hooks/pre-commit ${PWD}/.git/hooks/pre-commit
+       exec ${PWD}/.git/hooks/pre-commit
+fi
+
 if git rev-parse --verify HEAD &>/dev/null; then
        against=HEAD
 else
@@ -15,7 +21,7 @@ check_puppet_manifest () {
         git cat-file blob :0:${file} | sed 's/^import .*/#&/' >${pp}
         trap "rm -f ${pp}" RETURN
 
-        local output=$(puppet apply --noop --ignoreimport ${pp} 2>&1)
+        local output=$(puppet apply --noop ${pp} 2>&1)
         if [ $? -ne 0 ] || [ -n "${output}" ]; then
                 echo '** Syntax check failed:' >&2
                 echo "${output}" >&2