hooks/pre-commit: check syntax of all shell scripts

fdroid/privileged-extension#56
parent 4626f24d
Pipeline #42712322 passed with stage
in 11 minutes and 41 seconds
......@@ -34,6 +34,8 @@ test:
- echo "use versionCode that is known to exist on f-droid.org for test:"
- sed -i 's,versionCode="[^"]*",versionCode="2070",' app/src/main/AndroidManifest.xml
- ./create_ota.sh release binaries
- apt-get -qy install --no-install-recommends devscripts
- ./hooks/pre-commit
artifacts:
name: "${CI_PROJECT_PATH}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
paths:
......
......@@ -44,5 +44,39 @@ then
exit 1
fi
SH_FILES="hooks/pre-commit hooks/pre-push app/src/main/scripts/update-binary app/src/main/scripts/80-fdroid.sh"
err() {
echo >&2 ERROR: "$@"
exit 1
}
warn() {
echo >&2 WARNING: "$@"
}
for f in $SH_FILES; do
if ! bash -n $f; then
err "bash tests failed!"
fi
if which dash > /dev/null; then
if ! dash -n $f; then
err "dash tests failed!"
fi
else
warn "skipping dash tests"
fi
if which checkbashisms > /dev/null; then
test "$f" != "app/src/main/scripts/update-binary" || continue # this fails
if ! checkbashisms $f; then
err "checkbashisms tests failed!"
fi
else
warn "skipping checkbashisms tests"
fi
done
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment