Skip to content

chore: add project pre-commit hook mirroring CI#542

Merged
kwannoel merged 1 commit into
mainfrom
session-1-ce5c6a
Apr 22, 2026
Merged

chore: add project pre-commit hook mirroring CI#542
kwannoel merged 1 commit into
mainfrom
session-1-ce5c6a

Conversation

@kwannoel

Copy link
Copy Markdown
Owner

Summary

  • Adds .githooks/pre-commit that runs the same checks as .github/workflows/ci.ymlpnpm check, pnpm test, cargo +stable fmt --check, cargo +stable clippy -- -D warnings, cargo +stable test
  • Adds a prepare script to package.json that sets core.hooksPath=.githooks automatically after pnpm install, so every fresh clone and new worktree picks the hook up without any manual setup
  • Pins cargo steps to +stable to match CI's dtolnay/rust-toolchain@stable
  • Runs cargo test single-threaded to dodge a pre-existing shared-env-var flake between scaffold and worktree tests (followup issue recommended)
  • Clears GIT_DIR/GIT_INDEX_FILE/etc. before running checks — git exports them into hook environments, and subprocess git calls inside tests would otherwise target the parent repo rather than their tmp repos

Test plan

  • Fresh pnpm install in this worktree auto-set core.hooksPath to .githooks
  • git commit on this branch triggered the hook; all five checks ran and passed
  • Verify on a teammate's fresh clone that pnpm install alone activates the hook

🤖 Generated with Claude Code

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>
@kwannoel kwannoel enabled auto-merge (squash) April 22, 2026 13:41
@kwannoel kwannoel merged commit aab5039 into main Apr 22, 2026
3 checks passed
@kwannoel kwannoel deleted the session-1-ce5c6a branch April 22, 2026 13:43
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.

1 participant