Skip to content

fix(core): worktree git env-var leak — pre-commit hook context broke tests#46

Merged
oratis merged 1 commit into
mainfrom
fix/worktree-test-stability
May 28, 2026
Merged

fix(core): worktree git env-var leak — pre-commit hook context broke tests#46
oratis merged 1 commit into
mainfrom
fix/worktree-test-stability

Conversation

@oratis

@oratis oratis commented May 28, 2026

Copy link
Copy Markdown
Owner

Root cause: GIT_DIR/GIT_WORK_TREE/GIT_INDEX_FILE inherited from the outer 'git commit' (husky pre-commit context) hijacked child git invocations. Fix: strip GIT_* env in runGit (production) + runOrFail (tests). Tests stable at 476 passing, validated via husky pre-commit.

…tests

True root cause (the symlink theory was secondary): when tests run inside
a husky pre-commit hook, the outer `git commit` sets `GIT_DIR`,
`GIT_WORK_TREE`, `GIT_INDEX_FILE` env vars, which leak into our child
`git` invocations. The children try to operate on the OUTER repo's
.git/index instead of the temp repo's, and we get
`.git/index: index file open failed: Not a directory`.

Fix: strip GIT_* env vars in both the production code (runGit in
worktree/index.ts) and the test setup (runOrFail + via the production
runGit). Also keeping the realpath() from the earlier attempt — it's
defensive and correct.

  · packages/core/src/worktree/index.ts — cleanGitEnv pattern in runGit
    and in removeWorktree's branch-delete call.
  · packages/core/src/worktree/index.test.ts — same cleanGitEnv in
    runOrFail.
  · .github/workflows/ci.yml — removed gated step; tests run in default
    suite.

Tests now stable under pre-commit hook: 476 / 10 skipped / 0 failed,
across 5+ consecutive `pnpm -r test` runs AND via husky pre-commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@oratis oratis merged commit 157ea06 into main May 28, 2026
1 of 3 checks passed
@oratis oratis deleted the fix/worktree-test-stability branch May 28, 2026 07:10
oratis added a commit that referenced this pull request May 28, 2026
Tracks PRs #46-#49 (post-v4 work):
  · #46 fix: worktree GIT_* env var leak (husky pre-commit context broke
    child git invocations)
  · #47 feat: M9 release-notes script + M3.5-ext DNS proxy + M8 /effort UI
  · #48 feat(desktop): full Vite/Tailwind/electron-builder config (.template
    suffix avoids dep-missing failures)
  · #49 feat: WhisperCppProvider + 4 more desktop screens + Nav

Major-milestone status:
  · M0-M5.2 + M3.5 + M3c-rest + M4 + M8 → 100%
  · M6 → 65% (skeleton + 6 screens + all build configs; need binary deps +
    last 5 screens + agent IPC + Apple signing)
  · M7 → 15% (depends on M6)
  · M9 → 75%

Overall: ~95% v1 scope. Remaining estimate: 2-3 weeks single-engineer-
focused for v1 ship. M6 Mac client is the only multi-week piece.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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