Skip to content

chore(tests): git add -u in golangci-lint-fast.sh restages files outside the current commit's pathspec #1277

Description

@Wikid82

Problem

scripts/pre-commit-hooks/golangci-lint-fast.sh runs git add -u -- "$module/*.go" as an auto-restage step. This indiscriminately restages every modified .go file in the module, regardless of what's actually staged/pathspec-limited for the commit in progress — even for a pathspec-limited git commit -- <files> call.

Impact

Surfaced during the flaky-SQLite-test-cleanup fix (development commits 5e38d2c5..b9a46963): with 17 test files modified at once across a multi-commit PR, the first two narrow git commit -- <specific files> attempts accidentally swept in all 17 files because this hook silently re-added everything in the module. Required a git stash push -- <other files> / git stash pop workaround around each commit to keep commits scoped as intended.

This will bite anyone doing deliberately-sliced, multi-commit PRs (which CLAUDE.md's Commit Slicing Strategy explicitly asks for) whenever more than one file in a module is dirty at once.

Suggested fix

Scope the git add -u to the same pathspec the commit itself is using, or drop the auto-restage behavior in favor of linting only what's already staged.

Priority

Low-risk, dev-workflow-only — no runtime/production impact. Good candidate for next week's fix cycle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ci-cdgolowFuture enhancement, not urgenttestingTest suite

    Projects

    Status
    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions