Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ done
# exactly what the commit will contain, so a file formatted on disk but never re-staged cannot
# slip through, and unstaged edits cannot block a clean commit. git points GIT_INDEX_FILE at the
# right index for `commit -a` and `commit <path>` too, and checkout-index honours it. Every
# tracked file is exported, so the whole codebase is checked, not only the files being changed.
# tracked file is exported, so the whole codebase is checked, not only the files being changed;
# --ignore-skip-worktree-bits includes paths a sparse checkout or `update-index --skip-worktree`
# leaves out of the working tree.
snapshot=$(mktemp -d "${TMPDIR:-/tmp}/pre-commit.XXXXXX") || exit 1
trap 'rm -rf "$snapshot"' EXIT
trap 'exit 1' HUP INT TERM

git -C "$root" checkout-index --all --prefix="$snapshot/" || exit 1
git -C "$root" checkout-index --all --ignore-skip-worktree-bits --prefix="$snapshot/" || exit 1

# Some lint rules resolve imports, so the snapshot shares the installed dependencies.
ln -s "$root/node_modules" "$snapshot/node_modules" || exit 1
Expand Down
Loading