diff options
| author | Martin André <martin.andre@kvhasia.com> | 2015-01-15 11:58:42 +0900 |
|---|---|---|
| committer | Martin André <martin.andre@kvhasia.com> | 2015-01-19 16:43:55 +0900 |
| commit | dc3687b18b186273f1a15526a0f9c86406644fc4 (patch) | |
| tree | c664a0e264e3fcb3da78b625ce8e308616ddf17a /tools/pre-commit-hook | |
| parent | 13799455c20074cad967a0b6fbe50b883163b4fd (diff) | |
| download | kolla-ansible-dc3687b18b186273f1a15526a0f9c86406644fc4.tar.gz kolla-ansible-dc3687b18b186273f1a15526a0f9c86406644fc4.zip | |
Various fixes to pre-commit hook
Fix incorrect test in sh. Bash implements the new test with [[ that
accepts the double equal, however, this is not a bash script. On Debian
and derivates, this will be run by dash.
Make the script portable by not using GNU extensions of xargs.
Call `validate-all-*.sh` scripts whenever possible.
Have bashate look for /usr/bin/env style shebang as well.
Remove useless validate-json.sh file.
Change-Id: Id2d697f2e9ddaa66e25f71f410200528c1e0cf6b
Diffstat (limited to 'tools/pre-commit-hook')
| -rwxr-xr-x | tools/pre-commit-hook | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/tools/pre-commit-hook b/tools/pre-commit-hook index 475e05912..a136b97b4 100755 --- a/tools/pre-commit-hook +++ b/tools/pre-commit-hook @@ -5,7 +5,7 @@ RES=0 cd $TOPLEVEL -if [ "$1" == "--install" ]; then +if [ "$1" = "--install" ]; then ln -sf ../../tools/pre-commit-hook .git/hooks/pre-commit exit fi @@ -26,26 +26,19 @@ find . -type f echo "=== bashate checks ===" -find . -type f -print0 | - xargs -0 --no-run-if-empty egrep -lZ '^#!/bin/(ba)?sh' | - xargs -0 bashate || RES=1 +files=$(egrep -rlI '^#!/(bin/|usr/bin/env )(ba)?sh' .) +[ "$files" ] && (bashate $files || RES=1) echo "=== yaml checks ===" -find . -name '*.yaml' -print0 | - xargs -0 --no-run-if-empty ${TOPLEVEL}/tools/validate-yaml.py \ - || RES = 1 +${TOPLEVEL}/tools/validate-all-yaml.sh || RES=1 echo "=== json checks ===" -find . -name '*.json' -print0 | - xargs -0 --no-run-if-empty ${TOPLEVEL}/tools/validate-json.py \ - || RES=1 +${TOPLEVEL}/tools/validate-all-json.sh || RES=1 echo "=== maintainer checks ===" -find . -name Dockerfile -print0 | - xargs -0 --no-run-if-empty ${TOPLEVEL}/tools/validate-maintainer \ - || RES=1 +${TOPLEVEL}/tools/validate-all-maintainer.sh || RES=1 exit $RES |
