chore: add project pre-commit hook mirroring CI#542
Merged
Conversation
Adds a versioned `.githooks/pre-commit` that runs the same checks as `.github/workflows/ci.yml` (svelte-check, vitest, cargo fmt/clippy/test) so failures surface locally before push. A `prepare` script in package.json auto-sets `core.hooksPath=.githooks` after `pnpm install`, covering fresh clones and new worktrees without manual setup. Cargo steps are pinned to `+stable` to match CI's toolchain, cargo test runs single-threaded to avoid a pre-existing shared-env-var flake between scaffold and worktree tests, and the hook clears GIT_DIR and related env vars that git exports into hooks (which otherwise leak into test subprocesses and make them operate on the parent repo). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
.githooks/pre-committhat runs the same checks as.github/workflows/ci.yml—pnpm check,pnpm test,cargo +stable fmt --check,cargo +stable clippy -- -D warnings,cargo +stable testpreparescript topackage.jsonthat setscore.hooksPath=.githooksautomatically afterpnpm install, so every fresh clone and new worktree picks the hook up without any manual setup+stableto match CI'sdtolnay/rust-toolchain@stablecargo testsingle-threaded to dodge a pre-existing shared-env-var flake between scaffold and worktree tests (followup issue recommended)GIT_DIR/GIT_INDEX_FILE/etc. before running checks — git exports them into hook environments, and subprocessgitcalls inside tests would otherwise target the parent repo rather than their tmp reposTest plan
pnpm installin this worktree auto-setcore.hooksPathto.githooksgit commiton this branch triggered the hook; all five checks ran and passedpnpm installalone activates the hook🤖 Generated with Claude Code