Commit Graph
2 Commits
Author SHA1 Message Date
timothyandClaude Opus 5 77317e5c71 test(785): pin the pre-push premise to both platforms, measured not assumed
The docstring said "git 2.55, macOS; the same holds on Linux". The second half was an
assertion, and this repo's canonical disaster (#775, the BOM guard) is precisely a guard
that behaved differently on the platform nobody measured — macOS had `xxd`, the Linux
runner did not, and it was fail-open there for months.

So it was measured on the runner host (Linux, git 2.47.3) rather than reasoned about:

  * git exports GIT_DIR=<repo>/.git/worktrees/<wt> to pre-push on a push from a worktree
  * `git rev-parse --show-toplevel` from web/ with that GIT_DIR answers `<wt>/web`
  * the nested `git diff --exit-code` reports exit 0 on a drifted file

and all three new suites were run there: 25 passed. Disarming the `unset` on that host
reddens 4 of the 9, the same four as on macOS.

Refs: #785
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 21:29:00 +02:00
timothyandClaude Opus 5 d05d6623d1 test(785): pin .husky/pre-push's unset GIT_DIR ..., and measure why it matters
The one-line fix at pre-push:11 had nothing pinning it, and #785 ranks it third because
the regression is a relocation rather than a deletion — a tidy-up that reads as a no-op.

What the investigation established, since the comment above it asserts the mechanism
without stating when it applies (git 2.55):

  * git exports GIT_DIR to pre-push when the push comes FROM A WORKTREE, and exports
    nothing from the main tree. `process.shared-tree-readonly` makes the worktree the
    mandated way to work here, so the exposed path is the normal one, not an edge case.
  * with GIT_DIR set and GIT_WORK_TREE unset, git stops discovering the repo and treats
    the CURRENT DIRECTORY as the work tree: `git rev-parse --show-toplevel` from web/
    answers `<wt>/web`.
  * so `cd web && npm run check:api`'s `git diff --exit-code` compares against index
    paths that do not exist there and reports NO DIFF, exit 0. Generated-API drift ships
    and the gate prints success.

The test drives the real pre-push file unedited, in a real worktree, with that exact
environment; the hook calls are stubs (DERIVED from the file, so a new hook cannot leave
the harness dying at a missing script and calling that a red) and `npm` is a stand-in
whose `run check:api` performs the nested diff.

Both mutations witnessed red against the real file: deletion -> 4 failed, 5 passed;
relocation to the end -> 5 failed, 4 passed.

The relocation mutation was wrong in the first draft. Appending the `unset` at the end
also makes it the script's last statement, and a bare `unset` succeeds — so a
`returncode == 0` assertion held for a reason unrelated to the nested git call. The
stand-in npm now records the nested diff's OWN exit code and the mutations assert on
that. Verified by making the mutation a no-op: the test fails, as it must.

Refs: #785
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 21:29:00 +02:00