From 6de989cd0f7d12c9026f1811b79025fbdd2707d3 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Thu, 19 Mar 2026 21:21:32 +0100 Subject: [PATCH] Update how version number is determined --- web/build.mjs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/web/build.mjs b/web/build.mjs index 030578d..3914336 100644 --- a/web/build.mjs +++ b/web/build.mjs @@ -77,20 +77,23 @@ if (existsSync(workerSrc)) { // Get git version string let versionStr = 'unknown'; -let versionHash = 'unknown'; +let versionLink = 'https://github.com/nicoverbruggen/kobopatch-webui'; try { const hash = String(execSync('git rev-parse --short HEAD', { cwd: repoDir })).trim(); - versionHash = hash; let tag = ''; try { - tag = String(execSync('git describe --tags --exact-match', { cwd: repoDir, stdio: 'ignore' })).trim(); + tag = String(execSync('git describe --tags --exact-match', { cwd: repoDir })).trim(); } catch {} if (tag) { versionStr = tag; + const dirty = String(execSync('git status --porcelain', { cwd: repoDir })).trim(); + if (dirty) versionStr += ' (D)'; + versionLink = `https://github.com/nicoverbruggen/kobopatch-webui/releases/tag/${tag}`; } else { const dirty = String(execSync('git status --porcelain', { cwd: repoDir })).trim(); versionStr = dirty ? `${hash} (D)` : hash; + versionLink = `https://github.com/nicoverbruggen/kobopatch-webui/commit/${hash}`; } } catch {} @@ -121,7 +124,7 @@ html = html.replace( html = html.replace('', `${versionStr}`); html = html.replace( 'href="https://github.com/nicoverbruggen/kobopatch-webui"', - `href="https://github.com/nicoverbruggen/kobopatch-webui/commit/${versionHash}"` + `href="${versionLink}"` ); writeFileSync(join(distDir, 'index.html'), html);