Skip to content

feat: warn when a new worktree omits untracked nested git repos (meta-repos)#4677

Open
diegoesolorzano wants to merge 4 commits into
stablyai:mainfrom
diegoesolorzano:feat/nested-repo-warning
Open

feat: warn when a new worktree omits untracked nested git repos (meta-repos)#4677
diegoesolorzano wants to merge 4 commits into
stablyai:mainfrom
diegoesolorzano:feat/nested-repo-warning

Conversation

@diegoesolorzano
Copy link
Copy Markdown

Closes #4671

Problem

In meta-repo layouts (a parent repo containing independent nested git repos in subdirectories — e.g. frontend/, backend/ as their own repos, untracked by the parent), git worktree add only materializes files tracked by the parent. Orca creates the worktree without any hint, and the user lands in a tree with no application code. The auto-detected setup command (root lockfile install) reinforces the illusion of a complete checkout.

What this does

After a successful local create, if the source repo contains nested git repos not tracked by the parent, the create result carries a structured nestedRepos warning and the renderer shows a toast listing the directories (capped at 10, with the real remainder count), reusing the existing post-create toast pattern (localBaseRefRefresh). Creation itself is never blocked or failed — detection is best-effort and resolves null on any scan/git failure or timeout.

Tracked submodules never warn: candidates are filtered against staged gitlinks (git ls-files -z --stage, mode 160000) and .gitmodules declarations (git config --file .gitmodules) — those are intentional layouts that worktrees handle natively.

Implementation notes

  • Reuses the existing scanner (scanNestedRepos from project-groups/nested-repo-discovery.ts) via its filesystem injection point, with two per-call overrides: isSelectedPathGitRepo: () => false (the scanner early-returns on git repos — it was built for non-git project folders) and readTextFile: async () => '' (gitignored nested repos are exactly the meta-repo case this warning exists for; the scanner's hardcoded skip-dirs and symlink safety are preserved). The default filesystem is extracted into an exported factory in a separate, behavior-preserving commit.
  • Bounded work: depth ≤ 3, scanner cap 100, 5s timeout, exactly one ls-files + one config call regardless of candidate count. The scan runs concurrently with the create and is awaited just before the IPC result returns.
  • Cross-platform: pure string relativization (handles both separators), slash-normalized pathspecs/display, WSL toplevel translated to UNC before the fs scan.
  • Detection only runs for local git creates — remote (SSH) and folder-mode flows are untouched.

Tests

  • 22 unit/integration cases for the detector (gitlink/.gitmodules exclusion, gitignore-override integration test on a real temp dir, caps/remainder, timeout/error paths, Windows/WSL path forms, subprocess count).
  • IPC wiring cases in worktrees.test.ts (attach/absent/concurrency/rejection-safety/remote-not-invoked).
  • Renderer slice cases (toast content, truncation remainder, absent field, coexistence with the base-ref toast).
  • Scanner suite passes unchanged (the factory extraction is behavior-preserving).

X: @diegoesolorzano

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.

[Feature]: Warn when creating a worktree of a repo containing nested independent git repos (meta-repo layouts)

2 participants