The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
Flavored desktop builds no longer stamp themselves dirty (#129540)
Siddharth Balyan86f54bfdaa36
diff --git a/apps/desktop/scripts/build.mjs b/apps/desktop/scripts/build.mjsindex 3ef14860fc4..3c635c080fe 100644--- a/apps/desktop/scripts/build.mjs+++ b/apps/desktop/scripts/build.mjs@@ -10,6 +10,9 @@ export function buildSourceDesktop({ source = repoRoot, icons, run = execFileSynconst app = join(source, 'apps/desktop')const step = (script, args = []) => run(process.execPath, [join(source, script), ...args], { cwd: app, stdio: 'inherit' })step('apps/desktop/scripts/assert-root-install.mjs')+ // Stamp before the flavored icons land: they overwrite committed files, and+ // the stamp's git check would then call the checkout dirty.+ step('apps/desktop/scripts/write-build-stamp.mjs')// Default-brand icons are committed; only flavored release builds pass --icons.icons = resolve(icons ?? source)if (icons !== source) {@@ -17,7 +20,6 @@ export function buildSourceDesktop({ source = repoRoot, icons, run = execFileSyn// prepared pixels; do not create another Python environment to redraw them.cpSync(join(icons, 'apps/desktop/assets'), join(app, 'assets'), { recursive: true })}- step('apps/desktop/scripts/write-build-stamp.mjs')// locales/_keys.desktop.json is a committed artifact (i18n-keys.test.mjs pins it to en.ts);// the build must not write into the checkout — a dirty tree breaks `hermes update`.step('apps/desktop/scripts/stage-native-deps.mjs')diff --git a/apps/desktop/scripts/build.test.mjs b/apps/desktop/scripts/build.test.mjsnew file mode 100644index 00000000000..0f70b68c1f7--- /dev/null+++ b/apps/desktop/scripts/build.test.mjs@@ -0,0 +1,42 @@+import assert from 'node:assert/strict'+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { basename, dirname, join } from 'node:path'+import { afterEach, test } from 'vitest'++import { buildSourceDesktop } from './build.mjs'++const roots = []++afterEach(() => {+ for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true })+})++function put(path, text) {+ mkdirSync(dirname(path), { recursive: true })+ writeFileSync(path, text)+}++test('the install stamp is written while the committed assets are still in place', () => {+ const root = mkdtempSync(join(tmpdir(), 'desktop-build-order-'))+ roots.push(root)+ const source = join(root, 'source')+ const icons = join(root, 'icons')+ const asset = join(source, 'apps/desktop/assets/icon.ico')+ put(asset, 'committed icon')+ put(join(icons, 'apps/desktop/assets/icon.ico'), 'flavored icon')++ // write-build-stamp asks git whether tracked files changed, so it must see+ // the committed bytes, not the flavored copy.+ let seenByStamp+ buildSourceDesktop({+ source,+ icons,+ run: (_command, [script]) => {+ if (basename(script) === 'write-build-stamp.mjs') seenByStamp = readFileSync(asset, 'utf8')+ }+ })++ assert.equal(seenByStamp, 'committed icon')+ assert.equal(readFileSync(asset, 'utf8'), 'flavored icon')+})diff --git a/scripts/bundles/desktop.py b/scripts/bundles/desktop.pyindex aebe46450d5..974e8ec8019 100644--- a/scripts/bundles/desktop.py+++ b/scripts/bundles/desktop.py@@ -121,8 +121,10 @@ def _build_prepared(prepared, builder_args: list[str], variant: str | None) -> N# The admitted checkout stays clean across the whole build: packaging reads# its artwork from the workspace, so the render lives there only while# electron-builder holds it, and the final check proves it was handed back.+ # Stamp before the render lands: the stamp's git check would call the+ # checkout dirty while the flavored icons sit over committed files.+ run([node, "scripts/write-build-stamp.mjs"], cwd=desktop, env=env)with flavored_assets(icons / "apps/desktop/assets", desktop / "assets"):- run([node, "scripts/write-build-stamp.mjs"], cwd=desktop, env=env)run([node, "scripts/build/desktop.mjs", "--source", str(repo), "--icons", str(icons),"--stamp", str(desktop / "build/install-stamp.json"), "--native-deps", str(prepared.native),"--out", str(desktop / "dist")], cwd=repo, env=env)