fix(10): centralize semver comparison policy across hooks and changeset

This commit is contained in:
Tom Boucher
2026-05-24 18:14:56 -04:00
parent 7170120325
commit 6913dbcdb1
7 changed files with 143 additions and 88 deletions

View File

@@ -15,7 +15,12 @@ const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const { parseStateMd, formatGsdState, readGsdState } = require('../hooks/gsd-statusline.js');
const {
parseStateMd,
formatGsdState,
readGsdState,
isInstalledAheadOfLatest,
} = require('../hooks/gsd-statusline.js');
// ─── parseStateMd ───────────────────────────────────────────────────────────
@@ -217,6 +222,16 @@ describe('formatGsdState', () => {
});
});
describe('isInstalledAheadOfLatest', () => {
test('treats prerelease patch increment as ahead of prior stable', () => {
assert.equal(isInstalledAheadOfLatest('1.2.1-beta.1', '1.2.0'), true);
});
test('treats equal base version prerelease as not ahead', () => {
assert.equal(isInstalledAheadOfLatest('1.2.0-rc.1', '1.2.0'), false);
});
});
// ─── readGsdState ───────────────────────────────────────────────────────────
describe('readGsdState', () => {