diff options
| author | DJ O'Leary <dijitol@proton.me> | 2026-07-08 01:06:20 +0200 |
|---|---|---|
| committer | DJ O'Leary <dijitol@proton.me> | 2026-07-08 01:06:20 +0200 |
| commit | 4d088c9354c17c58478cf121349a314b4e0dd322 (patch) | |
| tree | 4ad0635107bd4ec741ab82fd738662bc32ae073b /.githooks/pre-commit | |
| parent | 970b9f872254612b673c3a09579ed902cade3c99 (diff) | |
set up and add sync package
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!" |
