























@@ -365,6 +365,23 @@ function expectGroupedShellCommand(remoteCommand: string, command: string): void
365365const remoteChangedGateEnvPrefix =
366366"OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 CI=1";
367367const remoteChangedGateExport = `export ${remoteChangedGateEnvPrefix};`;
368+const remoteChangedGateFetch =
369+'git fetch -q --depth=1 origin "$openclaw_changed_gate_base:refs/remotes/origin/main"';
370+371+function expectChangedGateGitBootstrap(remoteCommand: string): void {
372+expect(remoteCommand).toContain("command -v git");
373+expect(remoteCommand).toContain(
374+"openclaw_changed_gate_base=${OPENCLAW_CHANGED_GATE_BASE:-abc123}",
375+);
376+expect(remoteCommand).toContain(
377+'openclaw_changed_gate_remote_base="$(git rev-parse --verify refs/remotes/origin/main 2>/dev/null || true)"',
378+);
379+expect(remoteCommand).toContain(
380+'[ "$openclaw_changed_gate_remote_base" != "$openclaw_changed_gate_base" ]',
381+);
382+expect(remoteCommand).toContain("git init -q");
383+expect(remoteCommand).toContain(remoteChangedGateFetch);
384+}
368385369386afterAll(() => {
370387for (const dir of tempDirs.splice(0)) {
@@ -1985,7 +2002,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
19852002expect(result.stderr).toContain("syncing from temporary full checkout");
19862003expect(result.stderr).toContain("overlaying local HEAD as worktree changes from origin/main");
19872004expect(parseFakeCrabboxOutput(result).args.join(" ")).toContain(
1988-"if ! git status --short >/dev/null 2>&1; then rm -rf .git;",
2005+'openclaw_changed_gate_remote_base="$(git rev-parse --verify refs/remotes/origin/main 2>/dev/null || true)"',
19892006);
19902007expect(parseFakeCrabboxOutput(result).cwd).toContain("openclaw-crabbox-sync-");
19912008});
@@ -2036,10 +2053,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
20362053const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
20372054expect(result.status).toBe(0);
20382055expect(output.args).toContain("--shell");
2039-expect(remoteCommand).toContain("git init -q");
2040-expect(remoteCommand).toContain(
2041-"git fetch -q --depth=1 origin abc123:refs/remotes/origin/main",
2042-);
2056+expectChangedGateGitBootstrap(remoteCommand);
20432057expect(remoteCommand).toContain("git reset --mixed --quiet refs/remotes/origin/main");
20442058expect(remoteCommand).toContain("git add -A");
20452059expect(remoteCommand).toContain("git diff --cached --quiet");
@@ -2049,6 +2063,25 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
20492063);
20502064});
205120652066+it("rebuilds stale remote Git metadata before sparse changed gates", () => {
2067+const result = runWrapper(
2068+"provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n",
2069+["run", "--provider", "aws", "--", "corepack", "pnpm", "check:changed"],
2070+{
2071+gitResponses: {
2072+[GIT_CONFIG_SPARSE_KEY]: { stdout: "true\n" },
2073+[GIT_STATUS_PORCELAIN_KEY]: { stdout: "" },
2074+[GIT_MERGE_BASE_MAIN_HEAD_KEY]: { stdout: "abc123\n" },
2075+},
2076+},
2077+);
2078+2079+const output = parseFakeCrabboxOutput(result);
2080+const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
2081+expect(result.status).toBe(0);
2082+expectChangedGateGitBootstrap(remoteCommand);
2083+});
2084+20522085it("bootstraps Git metadata for non-sparse changed gates on remote raw syncs", () => {
20532086const result = runWrapper(
20542087"provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n",
@@ -2069,9 +2102,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
20692102expect(output.cwd).toContain("openclaw-crabbox-sync-");
20702103expect(output.args).toContain("--shell");
20712104expect(remoteCommand).toContain("git init -q");
2072-expect(remoteCommand).toContain(
2073-"git fetch -q --depth=1 origin abc123:refs/remotes/origin/main",
2074-);
2105+expect(remoteCommand).toContain(remoteChangedGateFetch);
20752106expect(remoteCommand).toMatch(
20762107/&& env OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 CI=1 corepack pnpm check:changed$/u,
20772108);
@@ -2106,9 +2137,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
21062137const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
21072138expect(result.status).toBe(0);
21082139expect(output.args).toContain("--shell");
2109-expect(remoteCommand).toContain(
2110-"git fetch -q --depth=1 origin abc123:refs/remotes/origin/main",
2111-);
2140+expect(remoteCommand).toContain(remoteChangedGateFetch);
21122141expect(remoteCommand).toMatch(
21132142/&& env OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 CI=1 corepack pnpm check:changed$/u,
21142143);
@@ -2131,9 +2160,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
21312160const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
21322161expect(result.status).toBe(0);
21332162expect(output.args.filter((arg) => arg === "--shell")).toHaveLength(1);
2134-expect(remoteCommand).toContain(
2135-"git fetch -q --depth=1 origin abc123:refs/remotes/origin/main",
2136-);
2163+expect(remoteCommand).toContain(remoteChangedGateFetch);
21372164expect(remoteCommand).toContain("openclaw_crabbox_bootstrap_macos_js");
21382165expectGroupedShellCommand(
21392166remoteCommand,
@@ -2247,9 +2274,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
22472274const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
22482275expect(result.status).toBe(0);
22492276expect(remoteCommand).toContain("git init -q");
2250-expect(remoteCommand).toContain(
2251-"git fetch -q --depth=1 origin abc123:refs/remotes/origin/main",
2252-);
2277+expect(remoteCommand).toContain(remoteChangedGateFetch);
22532278expect(remoteCommand).toContain(
22542279`&& export OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1; ${shellScript}`,
22552280);
@@ -2358,9 +2383,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
23582383const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
23592384expect(result.status).toBe(0);
23602385expect(remoteCommand).toContain("git init -q");
2361-expect(remoteCommand).toContain(
2362-"git fetch -q --depth=1 origin abc123:refs/remotes/origin/main",
2363-);
2386+expect(remoteCommand).toContain(remoteChangedGateFetch);
23642387expect(remoteCommand).toContain(`&& ${remoteChangedGateExport} ${shellScript}`);
23652388});
23662389@@ -2714,9 +2737,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
27142737const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
27152738expect(result.status).toBe(0);
27162739expect(output.args.filter((arg) => arg === "--shell")).toHaveLength(1);
2717-expect(remoteCommand).toContain(
2718-"git fetch -q --depth=1 origin abc123:refs/remotes/origin/main",
2719-);
2740+expect(remoteCommand).toContain(remoteChangedGateFetch);
27202741expect(remoteCommand).toMatch(
27212742/&& export OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1; env CI=1 pnpm check:changed$/u,
27222743);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。