You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(runtime): keep inherited GIT_* env from aiming worktree-removal tests at an outer repo - #35853
The worktree-removal tests build a throwaway Git repository and run real git commands in it. They also call Orca's own Git code, which runs git too. Neither cleared the Git environment variables inherited from the shell. When the tests run from inside a Git hook, Git sets GIT_DIR and GIT_INDEX_FILE in that environment. Every one of those commands then quietly operated on the outer repository instead of the throwaway one: commits, branches and worktrees were written into whatever repo the hook belonged to.
What Changed
runtime-failed-local-worktree-removal.test.ts now clears every inherited GIT_* variable before each test using vi.stubEnv, and restores them afterwards.
That covers both the test's own git() helper and Orca's Git calls under test, since both inherit the process environment.
Test-only. Product Git behaviour is unchanged.
Why
Reproduced on main by running this file with GIT_DIR pointing at a separate empty repository. All 15 tests still passed, but that repository then held the test's "seed" commit, its master branch, and a registered feature worktree. Run from a real hook, that repository would be the developer's own.
With this change and the same environment (GIT_DIR and GIT_INDEX_FILE set), all 15 tests pass and the outer repository stays empty.
Clearing the variables in the file covers both callers in one place. Passing a scrubbed env to the helper alone would still leave Orca's Git calls pointed at the outer repo.
Linked Issue
N/A (maintainer PR; no existing issue).
Visual Proof
N/A: test-only change.
Testing
pnpm test src/main/runtime/runtime-failed-local-worktree-removal.test.ts: 15/15 pass. Also 15/15 with GIT_DIR and GIT_INDEX_FILE pointing at an outer repo, which stays untouched (no commits, no worktrees).
pnpm tc, pnpm run check:code-quality:changed and the flaky-test pattern ratchet pass.
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
The suite is macOS-only (describe.skipIf(process.platform !== 'darwin')), so this has no Linux, Windows, SSH or wire impact. Other real-Git test files may share this exposure; a shared setup could clear these variables for every suite as a follow-up.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Walkthrough
The worktree-removal test now clears inherited GIT_* environment variables before initializing its scratch repository. Teardown unstubs environment variables after restoring mocks.
Priority: Low
Merge Risk: Minimal · up to 9294d
The test-only cleanup change is ready to merge with no identified merge-blocking risk.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title clearly identifies the test-only change that prevents inherited GIT_* variables from directing worktree-removal tests at an outer repository.
Description check
The description follows the repository template. It explains the problem, change, reason, testing, scope, platform impact, and checklist status. The maintainer-specific Linked Issue exception is addre…
Docstring Coverage
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description follows the repository template. It explains the problem, change, reason, testing, scope, platform impact, and checklist status. The maintainer-specific Linked Issue exception is addressed.
Full details: Docstring Coverage
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.
Finishing Touches
📝 Generate docstrings
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
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
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.
ELI5
The worktree-removal tests build a throwaway Git repository and run real
gitcommands in it. They also call Orca's own Git code, which runsgittoo. Neither cleared the Git environment variables inherited from the shell. When the tests run from inside a Git hook, Git setsGIT_DIRandGIT_INDEX_FILEin that environment. Every one of those commands then quietly operated on the outer repository instead of the throwaway one: commits, branches and worktrees were written into whatever repo the hook belonged to.What Changed
runtime-failed-local-worktree-removal.test.tsnow clears every inheritedGIT_*variable before each test usingvi.stubEnv, and restores them afterwards.git()helper and Orca's Git calls under test, since both inherit the process environment.Why
Reproduced on main by running this file with
GIT_DIRpointing at a separate empty repository. All 15 tests still passed, but that repository then held the test's "seed" commit, itsmasterbranch, and a registeredfeatureworktree. Run from a real hook, that repository would be the developer's own.With this change and the same environment (
GIT_DIRandGIT_INDEX_FILEset), all 15 tests pass and the outer repository stays empty.Clearing the variables in the file covers both callers in one place. Passing a scrubbed
envto the helper alone would still leave Orca's Git calls pointed at the outer repo.Linked Issue
N/A (maintainer PR; no existing issue).
Visual Proof
N/A: test-only change.
Testing
pnpm test src/main/runtime/runtime-failed-local-worktree-removal.test.ts: 15/15 pass. Also 15/15 withGIT_DIRandGIT_INDEX_FILEpointing at an outer repo, which stays untouched (no commits, no worktrees).pnpm tc,pnpm run check:code-quality:changedand the flaky-test pattern ratchet pass.Review
Agent skill upstream boundary
Notes
The suite is macOS-only (
describe.skipIf(process.platform !== 'darwin')), so this has no Linux, Windows, SSH or wire impact. Other real-Git test files may share this exposure; a shared setup could clear these variables for every suite as a follow-up.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)