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
e2e setup: don't let an inherited git env re-init the parent repo - #51805
When e2e tests were started from inside a git command (for example git bisect run), the test setup's git init could re-initialise the developer's own checkout as a bare repo. After that, git stopped working in every worktree of that checkout. Now the e2e runner drops that inherited git environment before anything runs.
Files
Added
Deleted
Net
Test
2
$\color{#1a7f37}{\Huge{\mathbf{+}}}$82
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$82
Prod
5
$\color{#1a7f37}{\Huge{\mathbf{+}}}$26
$\color{#cf222e}{\Huge{\mathbf{−}}}$16
$\color{#1a7f37}{\Huge{\mathbf{+}}}$10
What Changed
tests/playwright.config.ts now first imports the existing git-env scrub that Vitest already uses. The config loads in the Playwright runner and in every worker before global setup, fixtures, or app launches, so every git call and launched app in an e2e run starts without GIT_DIR, GIT_WORK_TREE, GIT_INDEX_FILE, GIT_COMMON_DIR and related variables.
The shared list now also removes GIT_CONFIG, which otherwise sends the seeder's plain git config user.* writes into whatever file it names (e.g. another repo's config), and the remaining repo-locating variables (GIT_CEILING_DIRECTORIES, GIT_IMPLICIT_WORK_TREE, GIT_GRAFT_FILE, GIT_SHALLOW_FILE, GIT_REPLACE_REF_BASE, GIT_NO_REPLACE_OBJECTS, GIT_SUPER_PREFIX). GIT_CONFIG_GLOBAL/SYSTEM/NOSYSTEM and -c values (GIT_CONFIG_COUNT/PARAMETERS) stay: they can't redirect a write, and the signing/compat setup relies on them.
pr-package-test-paths.mjs keeps Windows test routing for the renamed setup file.
Added tests/e2e/global-setup-inherited-git-env.unit.test.ts. It sets GIT_DIR to a linked worktree's git dir in a throwaway repo (the same value git bisect run exports), loads the Playwright config, runs the real seedTestRepository(), and checks that the throwaway repo's shared config still has core.bare=false and no user.name. A second case points GIT_CONFIG at an outside file and checks that seeding leaves it unchanged.
Why
git bisect run, git hooks, git rebase --exec and git submodule foreach export GIT_DIR to the commands they run. When the global setup ran plain git init in a temp folder with GIT_DIR=<repo>/.git/worktrees/<wt>, git re-initialised that repo. Because the path doesn't end in /.git, git guessed it was bare and wrote core.bare = true to the shared .git/config, which broke git in every worktree with "fatal: this operation must be run in a work tree". The git config user.* calls also wrote the E2E Test identity into it.
Clearing the variables once, where the runner loads its config, covers the global setup, worker fallback seeding, fixtures, and the Electron app under test (whose own git calls would otherwise also target the outer repo). That's simpler than passing an env to every git call.
Linked Issue
N/A (internal)
Visual Proof
N/A: test infrastructure only, no UI change.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Reproduced the original bug in a throwaway repo with a linked worktree: git bisect run of a script that does git init in a temp folder flipped the shared core.bare from false to true.
New tests pass; with the config import removed both fail (shared repo flipped to bare; outside config rewritten with E2E Test). With only GIT_CONFIG removed from the list, the second case fails.
pnpm check:code-quality:changed and pnpm tc:node pass (macOS).
Performance
None, because this only deletes a few environment variables once when the test runner loads its config.
Risk
Low. Only test runs change. Anyone who relied on an exported GIT_DIR reaching e2e tests now gets the checkout found from the working directory, which is the same repo in normal use. Back out with a plain revert.
Level: Low
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
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
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)
I stated the risk: what could break, for whom, and how to back it out
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)
No actionable comments were generated in the recent review.
Walkthrough
The Playwright configuration imports inherited Git environment setup before other imports. The setup removes selected inherited Git environment variables and retains the documented exceptions. The unit-selection setup list and TypeScript include list use the setup path. New tests check repository seeding when GIT_DIR points to a linked worktree and verify that a file named by GIT_CONFIG remains unchanged.
Merge Risk: Minimal · up to e7c28
This change stops inherited Git environment variables from making e2e setup rewrite a developer's checkout configuration. It affects only test tooling, and a regression test covers the scenario. No remaining merge risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: the e2e setup no longer lets an inherited git environment make the parent repository re-initialise. The PR scrubs inherited GIT_DIR and related variables in the Playwr…
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.
Description check
The description is detailed and covers most of the required template. It has a clear ELI5, a What Changed section, a Why section, Testing checkboxes with concrete steps (macOS run, reproduction, and a…
Full details: Title check
Explanation
The title names the main change: the e2e setup no longer lets an inherited git environment make the parent repository re-initialise. The PR scrubs inherited GIT_DIR and related variables in the Playwright config, which matches the title's subject and intent. The title is short and specific, and it uses a single sentence.
Full details: Description check
Explanation
The description is detailed and covers most of the required template. It has a clear ELI5, a What Changed section, a Why section, Testing checkboxes with concrete steps (macOS run, reproduction, and a failure check with the config import removed), a Performance line, and a Risk section with a level and backout plan. The Visual Proof section is correctly marked N/A with a reason. Two items are weak. The Linked Issue section says "N/A (internal)", but the template says a linked issue should always exist for outside contributors. The author appears to be a maintainer, so the special case may apply, but the description does not state that. The Testing section also does not name the platforms beyond macOS, and Windows/Linux/SSH impact is not verified. The AI Disclosure section is left as the unfilled template comment, which is acceptable only for internal contributors and is not confirmed here.
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
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
When e2e tests were started from inside a git command (for example
git bisect run), the test setup'sgit initcould re-initialise the developer's own checkout as a bare repo. After that, git stopped working in every worktree of that checkout. Now the e2e runner drops that inherited git environment before anything runs.What Changed
tests/playwright.config.tsnow first imports the existing git-env scrub that Vitest already uses. The config loads in the Playwright runner and in every worker before global setup, fixtures, or app launches, so every git call and launched app in an e2e run starts withoutGIT_DIR,GIT_WORK_TREE,GIT_INDEX_FILE,GIT_COMMON_DIRand related variables.GIT_CONFIG, which otherwise sends the seeder's plaingit config user.*writes into whatever file it names (e.g. another repo's config), and the remaining repo-locating variables (GIT_CEILING_DIRECTORIES,GIT_IMPLICIT_WORK_TREE,GIT_GRAFT_FILE,GIT_SHALLOW_FILE,GIT_REPLACE_REF_BASE,GIT_NO_REPLACE_OBJECTS,GIT_SUPER_PREFIX).GIT_CONFIG_GLOBAL/SYSTEM/NOSYSTEMand-cvalues (GIT_CONFIG_COUNT/PARAMETERS) stay: they can't redirect a write, and the signing/compat setup relies on them.pr-package-test-paths.mjskeeps Windows test routing for the renamed setup file.vitest-inherited-git-env-setup.tstoinherited-git-env-setup.ts, since Vitest and Playwright now share it (one list of variables). This matches the rename onlayout-owner-v2(fix(layout-owner): a held pane keeps its terminal until Reopen; e2e seeding ignores a hook's git env #51761), so the two branches merge cleanly.tests/e2e/global-setup-inherited-git-env.unit.test.ts. It setsGIT_DIRto a linked worktree's git dir in a throwaway repo (the same valuegit bisect runexports), loads the Playwright config, runs the realseedTestRepository(), and checks that the throwaway repo's shared config still hascore.bare=falseand nouser.name. A second case pointsGIT_CONFIGat an outside file and checks that seeding leaves it unchanged.Why
git bisect run, git hooks,git rebase --execandgit submodule foreachexportGIT_DIRto the commands they run. When the global setup ran plaingit initin a temp folder withGIT_DIR=<repo>/.git/worktrees/<wt>, git re-initialised that repo. Because the path doesn't end in/.git, git guessed it was bare and wrotecore.bare = trueto the shared.git/config, which broke git in every worktree with "fatal: this operation must be run in a work tree". Thegit config user.*calls also wrote theE2E Testidentity into it.Clearing the variables once, where the runner loads its config, covers the global setup, worker fallback seeding, fixtures, and the Electron app under test (whose own git calls would otherwise also target the outer repo). That's simpler than passing an env to every git call.
Linked Issue
N/A (internal)
Visual Proof
N/A: test infrastructure only, no UI change.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Reproduced the original bug in a throwaway repo with a linked worktree:
git bisect runof a script that doesgit initin a temp folder flipped the sharedcore.barefrom false to true.New tests pass; with the config import removed both fail (shared repo flipped to bare; outside config rewritten with
E2E Test). With onlyGIT_CONFIGremoved from the list, the second case fails.pnpm check:code-quality:changedandpnpm tc:nodepass (macOS).Performance
None, because this only deletes a few environment variables once when the test runner loads its config.
Risk
Low. Only test runs change. Anyone who relied on an exported
GIT_DIRreaching e2e tests now gets the checkout found from the working directory, which is the same repo in normal use. Back out with a plain revert.Level: Low
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)