ctx/.githooks/pre-commit
Ricardo Carneiro 22f6e8fde9 chore: add golangci-lint, GitHub Actions CI, and pre-commit hooks
Adds .golangci.yml (errcheck, govet, staticcheck, revive, gocyclo,
gocritic, nilerr, errorlint, etc.). Fixes all lint issues found:
- RpcError/wrapRpc renamed to RPCError/wrapRPC (revive var-naming)
- Shadow vars resolved in process.go, outline.go, project.go
- nilerr suppressed with justifying comments in git/collect.go and
  auto/detector.go (WalkDir / intentional empty-returns)
- if-else chain rewritten as switch in format.go (gocritic)
- gofmt applied to detector.go and client.go

Adds .github/workflows/ci.yml: lint (ubuntu), build+vet+test matrix
(ubuntu/windows/macos), and Roslyn helper build (windows). Validated
with actionlint (0 issues).

Adds .githooks/pre-commit + pre-commit.ps1 for local pre-commit checks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-28 00:30:54 -03:00

37 lines
863 B
Bash

#!/bin/sh
# ctx pre-commit hook — shell entry point (works in Git Bash on Windows)
# Delegates to pre-commit.ps1 on Windows, runs natively on Linux/macOS.
#
# To activate:
# git config core.hooksPath .githooks
set -e
if command -v powershell.exe >/dev/null 2>&1; then
# Windows: delegate to PowerShell script
exec powershell.exe -ExecutionPolicy Bypass -File .githooks/pre-commit.ps1
fi
# Linux / macOS: run directly
echo "Running gofmt..."
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
echo "Files not formatted with gofmt:"
echo "$unformatted"
echo
echo "Run: gofmt -w ."
exit 1
fi
echo "Running go vet..."
go vet ./...
if command -v golangci-lint >/dev/null 2>&1; then
echo "Running golangci-lint..."
golangci-lint run ./...
else
echo "warning: golangci-lint not installed, skipping"
fi
echo "pre-commit checks passed"