惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
量子位
大猫的无限游戏
大猫的无限游戏
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
Google DeepMind News
Google DeepMind News
小众软件
小众软件
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
Y
Y Combinator Blog
Microsoft Security Blog
Microsoft Security Blog
雷峰网
雷峰网
Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(doctor): canonicalize git checkout detection (#85735)...
giodl73-repo · 2026-05-23 · via Recent Commits to openclaw:main

@@ -0,0 +1,111 @@

1+

import fs from "node:fs/promises";

2+

import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

3+

import { maybeOfferUpdateBeforeDoctor } from "./doctor-update.js";

4+5+

const originalStdinIsTtyDescriptor = Object.getOwnPropertyDescriptor(process.stdin, "isTTY");

6+7+

const mocks = vi.hoisted(() => ({

8+

note: vi.fn(),

9+

runCommandWithTimeout: vi.fn(),

10+

runGatewayUpdate: vi.fn(),

11+

}));

12+13+

vi.mock("../process/exec.js", () => ({

14+

runCommandWithTimeout: mocks.runCommandWithTimeout,

15+

}));

16+17+

vi.mock("../infra/update-runner.js", () => ({

18+

runGatewayUpdate: mocks.runGatewayUpdate,

19+

}));

20+21+

vi.mock("../terminal/note.js", () => ({

22+

note: mocks.note,

23+

}));

24+25+

async function runOffer(params?: {

26+

root?: string;

27+

confirm?: (p: { message: string; initialValue: boolean }) => Promise<boolean>;

28+

}): Promise<Awaited<ReturnType<typeof maybeOfferUpdateBeforeDoctor>>> {

29+

const confirm = params?.confirm ?? vi.fn().mockResolvedValue(false);

30+

return await maybeOfferUpdateBeforeDoctor({

31+

runtime: {} as never,

32+

options: {},

33+

root: params?.root ?? "/repo/link",

34+

confirm,

35+

outro: vi.fn(),

36+

});

37+

}

38+39+

beforeEach(async () => {

40+

mocks.note.mockReset();

41+

mocks.runCommandWithTimeout.mockReset();

42+

mocks.runGatewayUpdate.mockReset();

43+

Object.defineProperty(process.stdin, "isTTY", {

44+

configurable: true,

45+

value: true,

46+

});

47+

});

48+49+

afterEach(() => {

50+

vi.restoreAllMocks();

51+

if (originalStdinIsTtyDescriptor) {

52+

Object.defineProperty(process.stdin, "isTTY", originalStdinIsTtyDescriptor);

53+

} else {

54+

delete (process.stdin as Partial<typeof process.stdin>).isTTY;

55+

}

56+

});

57+58+

describe("maybeOfferUpdateBeforeDoctor", () => {

59+

it("treats a linked package root as a git checkout when realpaths match", async () => {

60+

const confirm = vi.fn().mockResolvedValue(false);

61+

vi.spyOn(fs, "realpath").mockImplementation(async (candidate) => {

62+

const value = String(candidate);

63+

if (value === "/repo/link" || value === "/repo/real") {

64+

return "/repo/real";

65+

}

66+

return value;

67+

});

68+

mocks.runCommandWithTimeout.mockResolvedValue({

69+

stdout: "/repo/real\n",

70+

stderr: "",

71+

code: 0,

72+

killed: false,

73+

signal: null,

74+

termination: "exit",

75+

noOutputTimedOut: false,

76+

});

77+78+

await expect(runOffer({ root: "/repo/link", confirm })).resolves.toEqual({ updated: false });

79+80+

expect(confirm).toHaveBeenCalledWith({

81+

message: "Update OpenClaw from git before running doctor?",

82+

initialValue: true,

83+

});

84+

expect(mocks.note).not.toHaveBeenCalledWith(

85+

expect.stringContaining("This install is not a git checkout."),

86+

"Update",

87+

);

88+

});

89+90+

it("keeps package-manager guidance when git reports a different checkout", async () => {

91+

const confirm = vi.fn();

92+

vi.spyOn(fs, "realpath").mockImplementation(async (candidate) => String(candidate));

93+

mocks.runCommandWithTimeout.mockResolvedValue({

94+

stdout: "/repo/other\n",

95+

stderr: "",

96+

code: 0,

97+

killed: false,

98+

signal: null,

99+

termination: "exit",

100+

noOutputTimedOut: false,

101+

});

102+103+

await expect(runOffer({ root: "/repo/link", confirm })).resolves.toEqual({ updated: false });

104+105+

expect(confirm).not.toHaveBeenCalled();

106+

expect(mocks.note).toHaveBeenCalledWith(

107+

expect.stringContaining("This install is not a git checkout."),

108+

"Update",

109+

);

110+

});

111+

});