From 7542ab25ee0355755283707e629b31c82479dc2b Mon Sep 17 00:00:00 2001 From: Rodrigo Uroz Date: Thu, 29 Jan 2026 12:28:24 +0000 Subject: [PATCH] fix: skip control-ui restore when directory is not tracked by git --- src/infra/update-runner.ts | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/infra/update-runner.ts b/src/infra/update-runner.ts index 0735edb39..5dc9ebe4c 100644 --- a/src/infra/update-runner.ts +++ b/src/infra/update-runner.ts @@ -678,14 +678,23 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise< // Restore dist/control-ui/ to committed state to prevent dirty repo after update // (ui:build regenerates assets with new hashes, which would block future updates) - const restoreUiStep = await runStep( - step( - "restore control-ui", - ["git", "-C", gitRoot, "checkout", "--", "dist/control-ui/"], - gitRoot, - ), - ); - steps.push(restoreUiStep); + // Only attempt if the directory is tracked by git (older checkouts may still track it) + const lsFilesResult = await runCommand( + ["git", "-C", gitRoot, "ls-files", "--error-unmatch", "dist/control-ui/"], + { cwd: gitRoot, timeoutMs }, + ).catch(() => null); + const controlUiTracked = lsFilesResult?.code === 0; + + if (controlUiTracked) { + const restoreUiStep = await runStep( + step( + "restore control-ui", + ["git", "-C", gitRoot, "checkout", "--", "dist/control-ui/"], + gitRoot, + ), + ); + steps.push(restoreUiStep); + } const doctorStep = await runStep( step(