From 5a1ebbe246a4a7110c36bf97f46011a0f2310bfb Mon Sep 17 00:00:00 2001 From: Gerome Grignon Date: Tue, 3 Nov 2026 09:28:13 +0100 Subject: [PATCH] fix(build): reset the worktree before moving it to the new pin --- tools/lib/build-steps.mjs | 4 +++- tools/test/build-steps.test.mjs | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/lib/build-steps.mjs b/tools/lib/build-steps.mjs index c6923d9..cbb581e 100644 --- a/tools/lib/build-steps.mjs +++ b/tools/lib/build-steps.mjs @@ -27,9 +27,11 @@ export async function prepareWorktree(lang) { const dir = buildDir(lang); log.step(`build directory ${path.relative(rootDir, dir)} @ ${sha.slice(0, 10)}`); if (await exists(path.join(dir, '.git'))) { - await run('git', ['checkout', '--detach', '--quiet', sha], {cwd: dir}); + // Discard the previous overlay before moving: a dirty file that upstream changed between the + // old and the new pin makes a plain checkout abort ("would be overwritten by checkout"). await run('git', ['reset', '--hard', '--quiet'], {cwd: dir}); await run('git', ['clean', '-fdq'], {cwd: dir}); + await run('git', ['checkout', '--detach', '--quiet', sha], {cwd: dir}); } else { await run('git', ['worktree', 'prune'], {cwd: originDir}); await run('git', ['worktree', 'add', '--detach', dir, sha], {cwd: originDir}); diff --git a/tools/test/build-steps.test.mjs b/tools/test/build-steps.test.mjs index 1cab1f7..e7f495a 100644 --- a/tools/test/build-steps.test.mjs +++ b/tools/test/build-steps.test.mjs @@ -82,6 +82,20 @@ describe('prepareWorktree', () => { assert.ok((await read(path.join(dir, 'adev', 'src', 'index.html'))).includes(' { + const {commitAll} = await import('./helpers.mjs'); + const upstreamIndex = path.join(repo.origin, 'adev', 'src', 'index.html'); + await write(upstreamIndex, (await read(upstreamIndex)).replace(' {