aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.js14
-rw-r--r--src/app.js7
2 files changed, 17 insertions, 4 deletions
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 : ''}<style>${css}</style>
<div id="app"></div>
<script>${js}</script>
${pwa ? SW_REGISTER + '\n' : ''}</body>
-</html>`;
+</html>`.replaceAll('{{COMMIT}}', gitCommit());
}
if (import.meta.main) {
diff --git a/src/app.js b/src/app.js
index 9c793ab..d97b39f 100644
--- a/src/app.js
+++ b/src/app.js
@@ -230,9 +230,10 @@ function footer() {
h('span', { class: 'faint' }, ' · '),
t('footerSourceOn') + ' ',
h('a', { href: 'https://github.com/coinos/coinosv3', target: '_blank', rel: 'noopener' }, 'GitHub'),
- // The build stamp settles every "is my PWA fresh?" question at a glance
- // ({{VERSION}} is filled at build time, like the service worker's).
- h('span', { class: 'faint' }, ' · {{VERSION}}')
+ // The commit stamp settles "is my PWA fresh?" AND "what code is this?"
+ // in one glance — filled at build time, links to the commit on GitHub.
+ h('span', { class: 'faint' }, ' · '),
+ h('a', { class: 'faint', href: 'https://github.com/coinos/coinosv3/commit/{{COMMIT}}', target: '_blank', rel: 'noopener' }, 'commit {{COMMIT}}')
),
h(
'div',