Files
yait/scripts/git-hooks/pre-commit
2026-01-08 17:18:53 +00:00

25 lines
465 B
Bash
Executable File

#!/bin/sh
#
# Run pre-commit checks on bin/yait. Requires `shellcheck` and a POSIX
# shell (duh).
me=$(basename "$0")
fmt() {
echo "${me}[$$]: $*"
}
script_path="./bin/yait"
if git diff --cached --name-only | grep -q "$script_path"; then
if shellcheck --enable=all --shell=sh "$script_path"; then
fmt "All tests passed."
exit 0
else
fmt "Syntax errors found in $script_path. Commit aborted."
exit 1
fi
fi
exit 0