Skip to content

Commit 886e5c0

Browse files
authored
fix(update): resolve detached dev status from origin (#124611)
* fix(update): resolve detached dev status from origin * test(update): split update status coverage * fix(update): preserve detached dev upstream * fix(update): read detached upstream config
1 parent 61a3d3e commit 886e5c0

7 files changed

Lines changed: 662 additions & 553 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3725,6 +3725,9 @@ describe("update-cli", () => {
37253725
},
37263726
assert: () => {
37273727
expect(getLogOutput()).toContain("OpenClaw update status");
3728+
expect(checkUpdateStatus).toHaveBeenCalledWith(
3729+
expect.objectContaining({ useDetachedDevUpstream: false }),
3730+
);
37283731
},
37293732
},
37303733
{
@@ -3759,6 +3762,9 @@ describe("update-cli", () => {
37593762
const channel = parsed.channel as { value?: unknown; config?: unknown };
37603763
expect(channel.value).toBe("dev");
37613764
expect(channel.config).toBe("dev");
3765+
expect(checkUpdateStatus).toHaveBeenCalledWith(
3766+
expect.objectContaining({ useDetachedDevUpstream: true }),
3767+
);
37623768
});
37633769

37643770
it("parses update status --json as the subcommand option", async () => {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export async function updateStatusCommand(opts: UpdateStatusOptions): Promise<vo
4848
root,
4949
timeoutMs: timeoutMs ?? 3500,
5050
fetchGit: true,
51+
useDetachedDevUpstream: configChannel === "dev",
5152
includeRegistry: true,
5253
resolveRegistryChannel: ({ installKind, git }) =>
5354
resolveStatusRegistryUpdateChannel({

‎src/infra/update-channels.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ export const UPDATE_EFFECTIVE_CHANNEL_ENV = "OPENCLAW_UPDATE_EFFECTIVE_CHANNEL";
2525
/** Git branch that represents the development update stream. */
2626
export const DEV_BRANCH = "main";
2727

28-
/** Resolves current tracking, or the configured Dev branch for detached HEAD. */
29-
export function resolveDevUpstreamRef(branch?: string | null, detached = false): string | null {
30-
if (branch !== "HEAD") {
31-
return "@{upstream}";
32-
}
33-
return detached ? `${DEV_BRANCH}@{upstream}` : null;
28+
/** Orders the configured Dev upstream before any detached-checkout fallbacks. */
29+
export function resolveDevUpstreamRefs(
30+
detached: boolean,
31+
fallbacks: readonly string[] = [],
32+
): string[] {
33+
return detached ? [`${DEV_BRANCH}@{upstream}`, ...fallbacks] : ["@{upstream}"];
3434
}
3535

3636
/** Normalizes config or CLI channel input to a supported update channel. */

0 commit comments

Comments
 (0)