Files
orca/src/main/git/command-runner
Brennan Benson 05688e7856 fix(git): stop starting Git in deleted project folders and for removed projects (#28822)
* fix(worktrees): skip Git sweeps for missing repo folders

* fix(worktrees): skip missing roots in headless scans

* fix(worktrees): check missing roots at Git listing boundary

* test(git): treat branch removal fixture as existing repo

* test(git): keep mocked worktree roots present for Git cases

* test(git): await host preflight in scan sharing fixtures

* revert(worktrees): drop the listing pre-check for missing repo folders

Reverts 82ccf05a4d, 13854fd3dc, c19604012a, 3f1b7ef64c, a868225608
and 962d9218c2. The reader-level stat ran in the wrong WSL distro, added
a wsl.exe spawn per listing, and only covered git worktree list. The next
commits replace it with a gate at the shared Git runner.

* fix(git): stop spawning Git in deleted native project folders

A registered project whose folder was deleted spawned a failing Git
process (spawn git ENOENT) on every sweep: git worktree list and the
git remote probes. The shared async Git runner now remembers, in memory,
a native cwd once a spawn ENOENT is followed by a definitive lstat
absence. Later calls for that cwd re-check with lstat before admission
and, while it is still absent, reject with the same spawn ENOENT shape
without starting a process. The entry is dropped as soon as the folder
exists again. WSL routes and UNC paths are never recorded, so their
behavior is unchanged.

The fenced-output readers move unchanged to captured-git-output.ts so
git-exec-file.ts stays under the file-length limit.

* fix(github): skip queued PR refreshes for removed projects

A PR-status refresh queued before its project was removed still ran
and probed Git (git remote) against the removed path. The drainer now
re-checks registration for each entry before any Git or GitHub call,
using the same predicate the refresh IPC entry points use, so every
removal path (sidebar, CLI, phone, closed window) and the rate-limit
re-queue are covered. The skip mirrors the existing not-visible skip,
so there is no new skip reason on the wire.

* fix(git,github): skip missing folders without a span; pure refresh registration

Round-2 review fixes.

- The known-missing-folder check now runs before withGitSpan in both
  async runners, so a skipped call starts no process and writes no
  git.exec span. The command is resolved lazily, only for a cwd already
  recorded, and the git.known_missing_cwd attribute is gone.
- The gate uses stat, which follows symlinks the way spawn's chdir does,
  so a symlinked project root whose target is gone is recorded too.
- The Set is re-checked after the stat, so concurrent first failures
  record and warn once.
- The PR-refresh drain check is now a pure predicate: is a project still
  registered at the candidate's path on its execution host. It reads the
  store each time and no longer resolves runtime Git options, which could
  throw inside the drain loop. Matching by path and host, not repo id,
  keeps a re-added project's coalesced refresh from being dropped.

* refactor(git,github): one wrapper per Git runner; drainer holds its check

Tripwire re-plan cuts, no behavior change except one Windows edge.

- The missing-folder gate is a single wrapper around each exported async
  runner (gitExecFileAsync outside the fetch-head lock, and
  gitExecFileAsyncBuffer). It decides "native" from the call's inputs
  (cwd set, not UNC, and no WSL distro on Windows) for both recording and
  checking, so the early command resolution and the second filter are
  gone. The span bodies are back to main's code.
- A Windows WSL project's linked worktree that runs host Git on a drive
  path is no longer recorded; before, it was recorded but never gated.
- The synthesized error is built from constants (spawn git ENOENT, empty
  stdout and stderr). Nothing reads spawnargs, and the buffer runner's
  only caller reads code and message.
- The drainer holds the registration check the way the event publisher
  holds its outcome observer, and the registration skip shares the
  existing not-visible skip.
2026-10-18 22:25:27 -07:00
..