diff options
Diffstat (limited to '.githooks/pre-commit')
| -rwxr-xr-x | .githooks/pre-commit | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..95ecd68 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# Pre-commit hook - fast checks only +# dependencies: php git bash grep xargs composer + +set -e + +echo "🔍 Running pre-commit checks..." + +# Check if we have staged files +if git diff --cached --quiet; then + echo "No staged changes found." + exit 0 +fi + +# Lint only staged files +echo "📝 Linting staged files..." + +# Get staged Go files +STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.go$' || true) + +if [ -n "$STAGED_FILES" ]; then + # Run Go linting on staged files + go vet ./... + if [ $? -eq 0 ]; then + echo "✅ go vet passed" + else + echo "❌ go vet failed" + exit 1 + fi + + golangci-lint run ./... + if [ $? -eq 0 ]; then + echo "✅ golangci-lint passed" + else + echo "❌ golangci-lint failed" + exit 1 + fi +else + echo "⏭️ Nothing to lint, skipping..." +fi + +echo "🎉 Pre-commit checks completed successfully!" |
