Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,16 @@ if git diff --cached --name-only | grep -q '\.go$'; then
echo "🔍 Checking for stale import paths..."
python3 tests/contract/check-import-paths.py
fi

# Check gofmt on staged Go files (--diff-filter=d: gofmt cannot read
# deleted files; xargs -I{} keeps one file per line, spaces-safe)
if git diff --cached --name-only | grep -q '\.go$'; then
unformatted=$(git diff --cached --name-only --diff-filter=d -- '*.go' | xargs -I{} gofmt -l -- {})
if [ -n "$unformatted" ]; then
echo "❌ gofmt found unformatted files:"
echo "$unformatted"
echo ""
echo "Run: gofmt -w <files>"
exit 1
fi
fi
Loading