X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=tools%2Fgit-hooks%2Fpre-commit;h=4406089770ba7baaaa39f81b915040a00a918e40;hb=cdf648b13dacc11edd25af11c93a67dbe7097743;hp=23e6e6aa2f4b7061ad1e2c5937e08a8643ff822f;hpb=66b30d19cf524bbae55a178445fbb6079ba07765;p=dsa-puppet.git diff --git a/tools/git-hooks/pre-commit b/tools/git-hooks/pre-commit index 23e6e6aa..44060897 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 parser validate ${pp} 2>&1) if [ $? -ne 0 ] || [ -n "${output}" ]; then echo '** Syntax check failed:' >&2 echo "${output}" >&2 @@ -64,7 +70,7 @@ check_puppet_manifest () { case "${file}" in manifests/site.pp|modules/*/manifests/*) if [[ -n "$(which puppet-lint)" ]]; then - puppet-lint --no-hard_tabs-check --no-80chars-check ${pp} >&2 | uniq + puppet-lint --no-hard_tabs-check --no-2sp_soft_tabs-check --no-80chars-check ${pp} >&2 | uniq else echo "Please install puppet-lint (gem install puppet-lint)" >&2 fi