Use commit count as patch version instead of raw git describe output.

This commit is contained in:
v.lagerev 2026-04-25 12:53:18 +03:00
parent 601f919fff
commit 806476001f

View file

@ -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}`;
}