9759a4c3a3
- Create scripts/build, scripts/test, scripts/run, scripts/install-hooks - Create git-hooks/pre-commit (auto-format staged .hs files) - Create git-hooks/pre-push (check formatting + hlint before push) - Handle git worktrees correctly in hook installation - Run fourmolu on all source files to fix existing formatting
24 lines
682 B
Bash
Executable File
24 lines
682 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Pre-push hook: check formatting and hlint before pushing.
|
|
# Installed by: scripts/install-hooks
|
|
set -euo pipefail
|
|
|
|
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
|
|
echo "--- Checking formatting with fourmolu..."
|
|
if ! "$PROJECT_DIR/hs" fourmolu --mode check app/ src/ test/; then
|
|
echo ""
|
|
echo "ERROR: Formatting check failed. Run './scripts/build' to auto-format."
|
|
echo " (fourmolu --mode inplace app/ src/ test/)"
|
|
exit 1
|
|
fi
|
|
echo "OK"
|
|
|
|
echo "--- Linting with hlint..."
|
|
if ! "$PROJECT_DIR/hs" hlint app/ src/ test/; then
|
|
echo ""
|
|
echo "ERROR: Hlint found warnings. Fix them before pushing."
|
|
exit 1
|
|
fi
|
|
echo "OK"
|