From 84a92a164950ba9922d526401bd643e057e20891 Mon Sep 17 00:00:00 2001 From: Stephen Gran Date: Wed, 25 Apr 2012 08:02:01 +0100 Subject: [PATCH] Update pre-commit hook 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 --- tools/git-hooks/pre-commit | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/git-hooks/pre-commit b/tools/git-hooks/pre-commit index 23e6e6aa..9d70e36c 100755 --- a/tools/git-hooks/pre-commit +++ b/tools/git-hooks/pre-commit @@ -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 -- 2.39.2