Skip to content

Commit add06de

Browse files
committed
fix(update): route stored dev package installs to git
1 parent 78b6d06 commit add06de

2 files changed

Lines changed: 47 additions & 2 deletions

File tree

‎src/cli/update-cli.test.ts‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5608,6 +5608,47 @@ describe("update-cli", () => {
56085608
expect(runDaemonRestart).not.toHaveBeenCalled();
56095609
expect(defaultRuntime.exit).not.toHaveBeenCalledWith(1);
56105610
});
5611+
5612+
it("routes a stored dev channel from a package install to the git update flow", async () => {
5613+
const packageRoot = createCaseDir("openclaw-update-package-root");
5614+
mockPackageInstallStatus(packageRoot);
5615+
const config = { update: { channel: "dev" } } as OpenClawConfig;
5616+
vi.mocked(readConfigFileSnapshot).mockResolvedValue({
5617+
...baseSnapshot,
5618+
parsed: config,
5619+
resolved: config,
5620+
sourceConfig: config,
5621+
runtimeConfig: config,
5622+
config,
5623+
});
5624+
await updateCommand({ dryRun: true, json: true, restart: false });
5625+
5626+
const preview = lastWriteJsonCall() as
5627+
| { updateInstallKind?: string; switchToGit?: boolean }
5628+
| undefined;
5629+
expect(preview?.updateInstallKind).toBe("git");
5630+
expect(preview?.switchToGit).toBe(true);
5631+
expect(packageInstallCommandCall()).toBeUndefined();
5632+
});
5633+
5634+
it("keeps a stored-dev package install on the package path for a one-off tag", async () => {
5635+
const packageRoot = createCaseDir("openclaw-update-package-root");
5636+
mockPackageInstallStatus(packageRoot);
5637+
const config = { update: { channel: "dev" } } as OpenClawConfig;
5638+
vi.mocked(readConfigFileSnapshot).mockResolvedValue({
5639+
...baseSnapshot,
5640+
parsed: config,
5641+
resolved: config,
5642+
sourceConfig: config,
5643+
runtimeConfig: config,
5644+
config,
5645+
});
5646+
5647+
await updateCommand({ tag: "latest", yes: true, restart: false });
5648+
5649+
expect(runGatewayUpdate).not.toHaveBeenCalled();
5650+
expectPackageInstallSpec("openclaw@latest");
5651+
});
56115652
it("explains why git updates cannot run with edited files", async () => {
56125653
vi.mocked(defaultRuntime.log).mockClear();
56135654
vi.mocked(defaultRuntime.error).mockClear();

‎src/cli/update-cli/update-command.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3401,7 +3401,12 @@ async function updateCommandInternal(opts: UpdateCommandOptions): Promise<void>
34013401
});
34023402
return;
34033403
}
3404-
const switchToGit = requestedChannel === "dev" && installKind !== "git";
3404+
// A configured dev channel is a Git checkout too. A one-off package tag
3405+
// deliberately stays package-scoped, unless the caller explicitly selects dev.
3406+
const explicitTag = normalizeTag(opts.tag);
3407+
const switchToGit =
3408+
installKind !== "git" &&
3409+
(requestedChannel === "dev" || (selectedChannel === "dev" && explicitTag === null));
34053410
const switchToPackage =
34063411
requestedChannel !== null && requestedChannel !== "dev" && installKind === "git";
34073412
const updateInstallKind = switchToGit ? "git" : switchToPackage ? "package" : installKind;
@@ -3411,7 +3416,6 @@ async function updateCommandInternal(opts: UpdateCommandOptions): Promise<void>
34113416
const devTargetRef =
34123417
channel === "dev" ? process.env.OPENCLAW_UPDATE_DEV_TARGET_REF?.trim() || undefined : undefined;
34133418

3414-
const explicitTag = normalizeTag(opts.tag);
34153419
if (channel === "extended-stable" && explicitTag) {
34163420
await reportPreMutationUpdateFailure({
34173421
root,

0 commit comments

Comments
 (0)