From 6fadff26c2a61e693dd6f4091754f4edf8b1df5a Mon Sep 17 00:00:00 2001 From: heaven Date: Sat, 25 Apr 2026 12:53:18 +0300 Subject: [PATCH] Use commit count as patch version instead of raw git describe output. --- vite.config.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vite.config.js b/vite.config.js index 0dac824f..c053c7d2 100644 --- a/vite.config.js +++ b/vite.config.js @@ -15,13 +15,21 @@ import buildConfig from './build.config'; function resolveAppVersion() { if (process.env.VITE_APP_VERSION) return process.env.VITE_APP_VERSION; try { - return execSync('git describe --tags --always --dirty', { + const raw = execSync('git describe --tags --always --dirty', { stdio: ['ignore', 'pipe', 'ignore'], }) .toString() .trim(); + const m = raw.match(/^(v?\d+\.\d+)\.\d+-(\d+)-g([0-9a-f]+)(-dirty)?$/); + if (m) { + const base = m[1]; + const patch = m[2]; + const hash = m[3]; + const dirty = m[4] ?? ''; + return `${base}.${patch}+g${hash}${dirty}`; + } + return raw; } catch { - // Fallback for builds without a usable .git (e.g. Docker — .git is in .dockerignore) const pkg = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8')); return `v${pkg.version}`; }