From 8e0bf7dc840ecdf6ba991c5e63d4c8304419342d Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 18 Aug 2026 09:20:17 -0700 Subject: The footer says what it stamps: the word commit, the short hash git actually knows, and a link to it — the build token stays where it belongs, inside the service worker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01JtaatFfAbx91Nh3xqKVqKz --- build.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'build.js') diff --git a/build.js b/build.js index 0c8cba2..6e1829d 100644 --- a/build.js +++ b/build.js @@ -245,6 +245,18 @@ const flagsPlugin = (staging) => ({ }, }); +// The commit this build came from: the deploy hook passes GIT_COMMIT (the +// worktree it builds in has no .git), local builds ask git directly. +function gitCommit() { + if (process.env.GIT_COMMIT) return process.env.GIT_COMMIT.slice(0, 7); + try { + const r = Bun.spawnSync(['git', 'rev-parse', '--short', 'HEAD']); + const out = r.stdout.toString().trim(); + if (/^[0-9a-f]{6,}$/.test(out)) return out; + } catch {} + return 'dev'; +} + export async function buildHtml({ minify = true, pwa = minify, features = process.env.HAL_FEATURES, staging = isStaging() } = {}) { const result = await Bun.build({ entrypoints: ['./src/app.js'], @@ -276,7 +288,7 @@ ${pwa ? PWA_HEAD : ''}
${pwa ? SW_REGISTER + '\n' : ''} -`; +`.replaceAll('{{COMMIT}}', gitCommit()); } if (import.meta.main) { -- cgit v1.2.3