fix(update): order stable correction releases after base

This commit is contained in:
Vincent Koc
2026-05-04 03:05:39 -07:00
parent feb9a5af6a
commit b8f6e16ba5
3 changed files with 14 additions and 0 deletions

View File

@@ -29,6 +29,12 @@ describe("compareSemverStrings", () => {
expect(compareSemverStrings("1.0.0", "1.0.0.beta.1")).toBe(1);
});
it("treats OpenClaw stable correction releases as newer than their base release", () => {
expect(compareSemverStrings("2026.5.3", "2026.5.3-1")).toBe(-1);
expect(compareSemverStrings("2026.5.3-1", "2026.5.3")).toBe(1);
expect(compareSemverStrings("2026.5.3-2", "2026.5.3-1")).toBe(1);
});
it("returns null for invalid inputs", () => {
expect(compareSemverStrings("1.0", "1.0.0")).toBeNull();
expect(compareSemverStrings("latest", "1.0.0")).toBeNull();

View File

@@ -3,6 +3,7 @@ import path from "node:path";
import { runCommandWithTimeout } from "../process/exec.js";
import { fetchWithTimeout } from "../utils/fetch-timeout.js";
import { detectPackageManager as detectPackageManagerImpl } from "./detect-package-manager.js";
import { compareOpenClawReleaseVersions } from "./npm-registry-spec.js";
import { compareComparableSemver, parseComparableSemver } from "./semver-compare.js";
import { channelToNpmTag, type UpdateChannel } from "./update-channels.js";
@@ -384,6 +385,12 @@ export async function resolveNpmChannelTag(params: {
}
export function compareSemverStrings(a: string | null, b: string | null): number | null {
if (a && b) {
const openClawReleaseCmp = compareOpenClawReleaseVersions(a, b);
if (openClawReleaseCmp != null) {
return openClawReleaseCmp;
}
}
return compareComparableSemver(
parseComparableSemver(a, { normalizeLegacyDotBeta: true }),
parseComparableSemver(b, { normalizeLegacyDotBeta: true }),