spark-server/scripts/git-hooks/pre-commit
2026-09-29 10:22:28 +08:00

19 lines
598 B
Bash
Executable File

#!/usr/bin/env bash
# Runs before every git commit. Install: make install-git-hooks
set -euo pipefail
ROOT="$(git rev-parse --show-toplevel)"
cd "$ROOT"
if ! command -v go >/dev/null 2>&1; then
echo "pre-commit: go not in PATH — install Go 1.26+ and golangci-lint; make test is mandatory before commit." >&2
exit 1
fi
if ! command -v golangci-lint >/dev/null 2>&1; then
echo "pre-commit: golangci-lint not in PATH — run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8" >&2
exit 1
fi
echo "pre-commit: make test (lint + go test + logic coverage)…" >&2
make test