dc3687b18b
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
45 lines
855 B
Bash
Executable File
45 lines
855 B
Bash
Executable File
#!/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 ==="
|
|
|
|
files=$(egrep -rlI '^#!/(bin/|usr/bin/env )(ba)?sh' .)
|
|
[ "$files" ] && (bashate $files || RES=1)
|
|
|
|
echo "=== yaml checks ==="
|
|
|
|
${TOPLEVEL}/tools/validate-all-yaml.sh || RES=1
|
|
|
|
echo "=== json checks ==="
|
|
|
|
${TOPLEVEL}/tools/validate-all-json.sh || RES=1
|
|
|
|
echo "=== maintainer checks ==="
|
|
|
|
${TOPLEVEL}/tools/validate-all-maintainer.sh || RES=1
|
|
|
|
exit $RES
|