You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(hooks): check the whole codebase as staged in pre-commit - #303
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 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.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
A relative TMPDIR prevents temporary snapshot cleanup.
0 open findings
Previously missed (1)
In code that hasn't changed since last review
Relative TMPDIR causes snapshot cleanup to fail
.githooks/pre-commit:31
If TMPDIR is relative, mktemp returns a relative path. After the hook changes into that directory, the EXIT trap resolves the path relative to the snapshot itself and fails to remove it, leaving a full source snapshot behind. Normalize the path before installing the trap.
Went through Copilot's previously-missed comment and it was valid:
.githooks/pre-commit:31 — fixed (lands with the next push). A relative TMPDIR gave a relative snapshot path that the EXIT trap resolved from inside the snapshot after the cd, leaking the whole snapshot. The path is now anchored to the hook's working directory before the trap is installed. Verified cleanup with relative, absolute and unset TMPDIR.
Also anchor a relative TMPDIR to the hook's working directory before
installing the EXIT trap, which otherwise resolved the path from
inside the snapshot after the cd and left the snapshot behind.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
commit -aandcommit <path>are covered too, because git pointsGIT_INDEX_FILEat the right index.checkout-indexruns with--ignore-skip-worktree-bits, so files hidden by a sparse checkout orgit update-index --skip-worktreeare 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.No CHANGELOG entry, since nothing under
src/changed.Test plan
npm run format:checkandnpm run lintsrc/