Skip to content

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

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

Sparse-checkout entries are omitted from the snapshot, undermining whole-index validation.

1 open finding
What changed in this PR

Updates pre-commit validation to inspect a temporary snapshot of the Git index rather than the working tree.

Changes:

  • Exports the index before running formatting and lint checks.
  • Documents the snapshot-based hook behavior and shared repositories.
File Description
.githooks/​pre-commit Checks formatting and linting against an index snapshot.
AGENTS.md Documents the revised hook behavior.

🧠 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 Outdated
Copilot AI balanced review requested due to automatic review settings October 10, 2026 17:09

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

The hook diverges from the repositories where it must remain byte-identical.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

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.

🟢 Approval recommended

The snapshot handling and documentation match the intended behavior, with no unresolved findings.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

@paustint
paustint merged commit 35e6dac into main Oct 16, 2026
13 checks passed
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