diff options
| author | Jenkins <jenkins@review.openstack.org> | 2014-10-14 19:44:51 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2014-10-14 19:44:51 +0000 |
| commit | ec5a16dcecce315b2a3f546d19589e817a526caf (patch) | |
| tree | bfeb40342cbd943f90b18a3e99caa8475ed84f6c /tools/pre-commit-hook | |
| parent | 358e99668282127e2aeed0b76f5714ce043c1c4b (diff) | |
| parent | bfbf1b8c9b3a0abba86474aeb72b950142723d73 (diff) | |
| download | kolla-ec5a16dcecce315b2a3f546d19589e817a526caf.tar.gz kolla-ec5a16dcecce315b2a3f546d19589e817a526caf.zip | |
Merge "add better validation checks (part 1)"
Diffstat (limited to 'tools/pre-commit-hook')
| -rwxr-xr-x | tools/pre-commit-hook | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tools/pre-commit-hook b/tools/pre-commit-hook new file mode 100755 index 000000000..699cb978e --- /dev/null +++ b/tools/pre-commit-hook @@ -0,0 +1,45 @@ +#!/bin/sh + +TOPLEVEL=$(git rev-parse --show-toplevel) +RES=0 + +cd $TOPLEVEL + +if [ "$1" == "--install" ]; then + ln -sf ../../tools/pre-commit-hook .git/hooks/pre-commit + exit +fi + +tmpdir=$(mktemp -d precommit.XXXXXX) || exit 1 +trap "rm -rf $TOPLEVEL/$tmpdir" 0 + +git diff --cached --name-only --diff-filter=ACMR | + xargs git checkout-index --prefix=$tmpdir/ -- + +cd $tmpdir + +echo "=== starting pre-commit checks ===" + +echo "Checking the following files:" + +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 + +echo "=== yaml checks ===" + +find . -name '*.yaml' -print0 | + xargs -0 --no-run-if-empty python ${TOPLEVEL}/tools/try-parse-yaml.py + +echo "=== json checks ===" + +find . -name '*.json' -print0 | + xargs -0 -n1 --no-run-if-empty python -mjson.tool \ + || RES=1 + +exit $RES + |
