Files
clan-core/scripts/pre-commit
DavHau 112982a7fb vars: add get_prompts api endpoint
vars: add test for api endpoint get_prompts
2024-09-04 17:36:50 +02:00

29 lines
567 B
Bash
Executable File

#!/usr/bin/env bash
# To install:
# ln -sf ../../scripts/pre-commit .git/hooks/pre-commit
set -o errexit
set -o nounset
set -o pipefail
readarray staged < <(git diff --name-only --cached)
[[ ${#staged[@]} = 0 ]] && exit
unstash() {
local ret=$?
set +e
git stash pop -q
exit "$ret"
}
git stash push --quiet --keep-index --message "pre-commit"
trap unstash EXIT
treefmt
{
changed=$(git diff --name-only --exit-code);
status=$?;
} || true
if [[ $status -ne 0 ]]; then
exec 1>&2
echo Files changed by pre-commit hook:
echo "$changed"
exit $status
fi