mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-07-10 00:14:38 +00:00
Scope pre-commit golangci-lint to staged packages with bounded concurrency
Lint only the packages containing staged .go files (falling back to ./... when none are staged) and cap golangci-lint concurrency/timeout via GOLANGCI_LINT_CONCURRENCY and GOLANGCI_LINT_TIMEOUT to keep the hook from exhausting resources on large trees.
This commit is contained in:
parent
b47a81173f
commit
cc6175d787
1 changed files with 4 additions and 1 deletions
|
|
@ -68,7 +68,10 @@ gofmt -w -s .
|
|||
# Run Go linting (if golangci-lint is available)
|
||||
if command -v golangci-lint >/dev/null 2>&1; then
|
||||
echo "Running golangci-lint..."
|
||||
golangci-lint run ./...
|
||||
STAGED_GO_PKGS=$(git diff --cached --name-only | grep '\.go$' | xargs -I{} dirname {} 2>/dev/null | sort -u | sed 's|^|./|' | tr '
|
||||
' ' ')
|
||||
if [ -z "$STAGED_GO_PKGS" ]; then STAGED_GO_PKGS="./..."; fi
|
||||
GOMAXPROCS="${GOMAXPROCS:-2}" golangci-lint run --concurrency "${GOLANGCI_LINT_CONCURRENCY:-2}" --timeout "${GOLANGCI_LINT_TIMEOUT:-5m}" $STAGED_GO_PKGS
|
||||
fi
|
||||
|
||||
# Run frontend linting (if package.json has lint script)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue