Skip to content

test(runtime): keep inherited GIT_* env from aiming worktree-removal tests at an outer repo - #35853

Merged
nwparker merged 1 commit into
mainfrom
nwparker/worktree-removal-test-git-env
Oct 29, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/worktree-removal-test-git-env

Conversation

@nwparker

@nwparker nwparker commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5
Prod 0 0 0 0

ELI5

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)

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

The tests now clear inherited GIT_* variables before creating their temporary repository and restore them afterward.

  • Worktree-removal tests ignore inherited Git settings.

Reviews (1) · Last reviewed commit: "test(runtime): keep inherited GIT_* env ..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d3d27ca7-9845-4093-8ade-554ac5da0d30
Commits

Reviewing files that changed from the base of the PR and between be80a9a and 9294d00.

Files selected for processing: 1
  • src/main/runtime/runtime-failed-local-worktree-removal.test.ts

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: Passed 5
Check name Status Explanation
Title check Passed The title clearly identifies the test-only change that prevents inherited GIT_* variables from directing worktree-removal tests at an outer repository.
Description check Passed 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 Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 6a03ed4 into main Oct 29, 2026
40 checks passed
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