Skip to content

fix(hooks): check the whole codebase as staged in pre-commit - #71

Merged
paustint merged 2 commits into
mainfrom
fix/pre-commit-index-snapshot
Oct 16, 2026
Merged

paustint merged 2 commits into
mainfrom
fix/pre-commit-index-snapshot

Conversation

@paustint

@paustint paustint commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The pre-commit hook now checks a snapshot of the index across the whole codebase. It used to pass staged paths to oxfmt and oxlint, which then read the working tree, so a file formatted on disk but never re-staged could slip through and unstaged edits could block a clean commit. commit -a and commit <path> are covered too, because git points GIT_INDEX_FILE at the right index.
  • The hook header now names all four repos that share it, so every copy is byte-identical. This mirrors chore: adopt oxfmt and oxlint with a pre-commit hook simple-xml#19.
  • checkout-index runs with --ignore-skip-worktree-bits, so files hidden by a sparse checkout or git update-index --skip-worktree are checked too. simple-xml gets the same change in fix(hooks): export skip-worktree entries into the pre-commit snapshot simple-xml#20, which keeps all four copies byte-identical.
  • AGENTS.md describes the new behavior.

No CHANGELOG entry, since nothing under src/ changed.

Test plan

  • Hook passes on a clean index, matching npm run format:check and npm run lint
  • Hook blocks an unformatted file staged under src/
  • Hook blocks a staged, unformatted file marked skip-worktree and removed from disk
  • Hook removes its temporary snapshot afterwards

The hook passed staged paths to oxfmt and oxlint, which read the working tree. A file formatted on disk but never re-staged could slip through, and unstaged edits could block a clean commit. It now exports the index to a temporary directory and checks every tracked file there, so it sees exactly what the commit will contain. The header names all four repos sharing the hook, so every copy is byte-identical.
Copilot AI balanced review requested due to automatic review settings October 10, 2026 16:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A relative TMPDIR prevents the temporary snapshot from being removed.

1 open finding
What changed in this PR

Updates the pre-commit hook to validate the complete staged index snapshot rather than working-tree files.

Changes:

  • Checks formatting and linting in a temporary index snapshot.
  • Documents the updated hook behavior and shared repositories.
File Description
.githooks/​pre-commit Creates and validates the staged snapshot.
AGENTS.md Documents whole-codebase index checking.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .githooks/pre-commit

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The repository-sharing guidance in AGENTS.md still contradicts the new four-repository contract.

1 open finding
Previously missed (1)

In code that hasn't changed since last review

Low severity Update AGENTS.md for the four-repository hook contract

.githooks/​pre-commit:10

Please also update AGENTS.md:113-116: it still says this hook is shared only with soql-parser-js and instructs contributors to sync only those two copies. That contradicts this new four-repository contract and can let the simple-excel and simple-xml copies drift during future changes.

🧠 Review effort: Balanced

Also normalize the snapshot path to an absolute one before installing
the EXIT trap. A relative TMPDIR made mktemp return a relative path,
which the trap then resolved from inside the snapshot after the cd and
so never removed. The hook runs from the worktree root, so prefixing
$PWD is exact.

AGENTS.md now names simple-excel and simple-xml alongside
soql-parser-js as the repositories the hook, release scripts and
workflows are shared with, matching the hook header.
Copilot AI balanced review requested due to automatic review settings October 16, 2026 12:53
@paustint
paustint force-pushed the fix/pre-commit-index-snapshot branch from 5d86226 to 2fbbb34 Compare October 16, 2026 12:53
@paustint

Copy link
Copy Markdown
Contributor Author

Went through Copilot's suppressed (low-confidence) comment — it was valid:

  • AGENTS.md:113-116 — fixed, the sharing note now names simple-excel and simple-xml alongside soql-parser-js, matching the hook header. All three sibling repos carry the same six files.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The snapshot handling, cleanup, and failure propagation match the intended behavior, with no unresolved findings.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

@paustint
paustint merged commit 1de71bc into main Oct 16, 2026
10 checks passed
@paustint
paustint deleted the fix/pre-commit-index-snapshot branch October 16, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants