Skip to content

Commit fa84518

Browse files
stevenepalmersteipete
authored andcommitted
fix(update): exclude prerelease tags from stable git channel
1 parent 9a60fcf commit fa84518

3 files changed

Lines changed: 43 additions & 2 deletions

File tree

‎src/infra/update-channels.test.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
channelToNpmTag,
44
formatUpdateChannelLabel,
55
isBetaTag,
6+
isPrereleaseTag,
67
isStableTag,
78
normalizeUpdateChannel,
89
resolveEffectiveUpdateChannel,
@@ -17,12 +18,24 @@ describe("update-channels tag detection", () => {
1718
{ tag: "v2026.2.24-beta.1", beta: true },
1819
{ tag: "v2026.2.24.beta.1", beta: true },
1920
{ tag: "v2026.2.24-BETA-1", beta: true },
21+
{ tag: "v2026.2.24-alpha.1", beta: false },
2022
{ tag: "v2026.2.24-1", beta: false },
2123
{ tag: "v2026.2.24-alphabeta.1", beta: false },
2224
{ tag: "v2026.2.24", beta: false },
2325
])("classifies $tag", ({ tag, beta }) => {
2426
expect(isBetaTag(tag)).toBe(beta);
25-
expect(isStableTag(tag)).toBe(!beta);
27+
});
28+
29+
it.each([
30+
{ tag: "v2026.2.24-alpha.1", prerelease: true, stable: false },
31+
{ tag: "v2026.2.24-beta.1", prerelease: true, stable: false },
32+
{ tag: "v2026.2.24-rc.1", prerelease: true, stable: false },
33+
{ tag: "v2026.2.24-preview.1", prerelease: true, stable: false },
34+
{ tag: "v2026.2.24-1", prerelease: false, stable: true },
35+
{ tag: "v2026.2.24", prerelease: false, stable: true },
36+
])("stable/prerelease classification for $tag", ({ tag, prerelease, stable }) => {
37+
expect(isPrereleaseTag(tag)).toBe(prerelease);
38+
expect(isStableTag(tag)).toBe(stable);
2639
});
2740
});
2841

‎src/infra/update-channels.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ export function isBetaTag(tag: string): boolean {
3737
return /(?:^|[.-])beta(?:[.-]|$)/i.test(tag);
3838
}
3939

40+
export function isPrereleaseTag(tag: string): boolean {
41+
return /(?:^|[.-])(alpha|beta|rc|pre|preview|canary|dev)(?:[.-]|$)/i.test(tag);
42+
}
43+
4044
export function isStableTag(tag: string): boolean {
41-
return !isBetaTag(tag);
45+
return !isPrereleaseTag(tag);
4246
}
4347

4448
export function resolveRegistryUpdateChannel(params: {

‎src/infra/update-runner.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,30 @@ describe("runGatewayUpdate", () => {
742742
expect(calls).not.toContain(`git -C ${tempDir} checkout --detach ${betaTag}`);
743743
});
744744

745+
it("uses stable tag for stable channel even when a newer alpha tag sorts first", async () => {
746+
await setupGitCheckout({ packageManager: "[email protected]" });
747+
await setupUiIndex();
748+
const stableTag = "v2026.5.22";
749+
const alphaTag = "v2026.5.24-alpha.1";
750+
const doctorNodePath = await resolveStableNodePath(process.execPath);
751+
const { runner, calls } = createRunner({
752+
...buildStableTagResponses(alphaTag, { additionalTags: [stableTag] }),
753+
[`git -C ${tempDir} checkout --detach ${stableTag}`]: { stdout: "" },
754+
"pnpm install": { stdout: "" },
755+
"pnpm build": { stdout: "" },
756+
"pnpm ui:build": { stdout: "" },
757+
[`${doctorNodePath} ${path.join(tempDir, "openclaw.mjs")} doctor --non-interactive --fix`]: {
758+
stdout: "",
759+
},
760+
});
761+
762+
const result = await runWithRunner(runner, { channel: "stable" });
763+
764+
expect(result.status).toBe("ok");
765+
expect(calls).toContain(`git -C ${tempDir} checkout --detach ${stableTag}`);
766+
expect(calls).not.toContain(`git -C ${tempDir} checkout --detach ${alphaTag}`);
767+
});
768+
745769
it("bootstraps pnpm via npm when pnpm and corepack are unavailable", async () => {
746770
await setupGitPackageManagerFixture();
747771
const stableTag = "v1.0.1-1";

0 commit comments

Comments
 (0)