History

ci: auto-format staged code with a pre-commit hook

Adds .githooks/pre-commit that runs oxfmt --write on staged JS/TS/JSON and re-stages them, and wires git config core.hooksPath .githooks into bootstrap so every fresh checkout and worktree activates it. Commits now land already-formatted, so the CI format job (oxfmt --check) stops failing on contributions that skipped running format manually. The hook only touches staged files, matching the existing rule to stage just your own files. It honours .oxfmtrc.json ignorePatterns and no-ops when oxfmt is not yet installed.

Rhys Sullivan committed 4 months ago

Commit de0ad501 parent 6b186bf2 files · +53 −0Browse files

Showing the changes to scripts (1 of 2 files). Show all

Unified · Split

scripts/bootstrap.ts+6−0
@@ -31,4 +31,10 @@ if (!existsSync(resolve(repoRoot, "node_modules/.bin/vitest"))) { · 30 unmodified lines
3131 throw new Error("bootstrap: vitest missing after install — bun install likely failed");
3232 }
3333
34+// Point git at the tracked .githooks dir so the pre-commit hook auto-formats
35+// staged code with oxfmt. hooksPath is local config, never cloned or copied
36+// into worktrees, so every fresh checkout and agent worktree must re-set it;
37+// without it, unformatted commits slip through and CI's `format` job fails.
38+run("git hooks", "git", ["config", "core.hooksPath", ".githooks"]);
39+
3440 console.log("\n[bootstrap] done — `cd e2e && bun run test` runs the full suite.");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t