From 60a810d89968a5f0cefdb9b9a968e104ac763bdd Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Thu, 30 Jul 2026 21:45:16 -0700 Subject: [PATCH] Distinguish expected absence from git errors in remote removal Why: swallowing all errors silently masks genuine git failures. Check presence explicitly instead, so setup/teardown can still skip when origin is absent while letting real errors surface. --- ...source-control-create-pr-intent-switch.spec.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/e2e/source-control-create-pr-intent-switch.spec.ts b/tests/e2e/source-control-create-pr-intent-switch.spec.ts index 281cdfccce8..816cf396d3c 100644 --- a/tests/e2e/source-control-create-pr-intent-switch.spec.ts +++ b/tests/e2e/source-control-create-pr-intent-switch.spec.ts @@ -26,11 +26,18 @@ async function writeEvidence( } function removeOriginRemoteIfPresent(cwd: string): void { - try { - execFileSync('git', ['remote', 'remove', 'origin'], { cwd, stdio: 'pipe' }) - } catch { - // Why: setup and teardown must not fail just because origin is absent. + // Why: check presence instead of swallowing errors, so real Git failures still surface. + const remotes = execFileSync('git', ['remote'], { + cwd, + encoding: 'utf8', + stdio: ['ignore', 'pipe', 'pipe'] + }) + .split('\n') + .map((line) => line.trim()) + if (!remotes.includes('origin')) { + return } + execFileSync('git', ['remote', 'remove', 'origin'], { cwd, stdio: 'pipe' }) } test.describe('Source Control Create PR intent worktree switching', () => {