pre-commit-install: fix install of golang shfmt pre-commit hook

This commit is contained in:
Tiziano Müller 2021-07-29 17:05:38 +02:00 committed by Tiziano Müller
parent e00c209c6d
commit 8fcca8f885

View file

@ -12,6 +12,14 @@ if [ -z "${PYTHON}" ]; then
exit 1
fi
GOLANG=$(command -v go || true)
if [ -z "${GOLANG}" ]; then
# TODO: bootstrap go as well, maybe use https://github.com/stefanmaric/g
echo "ERROR: did not find a 'go' executable, required for some of the pre-commit hooks"
exit 1
fi
SCRIPTDIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
# here we assume that this script is located in the tools/ subfolder
@ -71,6 +79,9 @@ echo "Installing pre-commit..."
PRE_COMMIT=$(command -v pre-commit)
# Enable Go 11 style modules for shfmt
export GO111MODULE=on
echo "Letting pre-commit setup the rest..."
"${PRE_COMMIT}" install --install-hooks