diff --git a/script/upstream/transforms/skip-files.ts b/script/upstream/transforms/skip-files.ts index f4d10bfee6..ded740a4cd 100644 --- a/script/upstream/transforms/skip-files.ts +++ b/script/upstream/transforms/skip-files.ts @@ -90,11 +90,19 @@ async function fileExistsInRef(file: string, ref: string): Promise { } /** - * Remove a file from the merge (git rm) + * Remove a file from the merge (git rm). Retries once on failure since + * transient index contention (editor watchers, rerere passes) has been + * observed to make the first attempt fail sporadically. */ -async function removeFile(file: string): Promise { - const result = await $`git rm -f ${file}`.quiet().nothrow() - return result.exitCode === 0 +async function removeFile(file: string): Promise<{ ok: boolean; err?: string }> { + const first = await $`git rm -f ${file}`.quiet().nothrow() + if (first.exitCode === 0) return { ok: true } + + const retry = await $`git rm -f ${file}`.quiet().nothrow() + if (retry.exitCode === 0) return { ok: true } + + const err = retry.stderr.toString().trim() || first.stderr.toString().trim() + return { ok: false, err } } /** @@ -143,12 +151,12 @@ export async function skipFiles(options: SkipOptions = {}): Promise