Skip to content

Commit 99d8549

Browse files
committed
fix(crabbox): always mark shell changed gates as remote
1 parent 7a077ff commit 99d8549

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

scripts/crabbox-wrapper.mjs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,11 +1591,7 @@ function injectRemoteChangedGateEnvironment(commandArgs) {
15911591
}
15921592

15931593
function markShellChangedGateAsRemoteChild(command) {
1594-
const missingEnv = remoteChangedGateEnv.filter((assignment) => !command.includes(assignment));
1595-
if (missingEnv.length === 0) {
1596-
return command;
1597-
}
1598-
return `export ${missingEnv.join(" ")}; ${command}`;
1594+
return `export ${remoteChangedGateEnv.join(" ")}; ${command}`;
15991595
}
16001596

16011597
function markDirectChangedGateAsRemoteChild(commandArgs) {

test/scripts/crabbox-wrapper.test.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2407,6 +2407,27 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
24072407
expectGroupedShellCommand(remoteCommand, `${remoteChangedGateExport} ${shellScript}`);
24082408
});
24092409

2410+
it("does not mistake quoted remote-child markers for shell changed-gate environment", () => {
2411+
const shellScript = 'echo "OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1"; pnpm check:changed';
2412+
const result = runWrapper(
2413+
"provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n",
2414+
["run", "--provider", "aws", "--target", "macos", "--shell", "--", shellScript],
2415+
{
2416+
gitResponses: {
2417+
[GIT_CONFIG_SPARSE_KEY]: { stdout: "true\n" },
2418+
[GIT_STATUS_PORCELAIN_KEY]: { stdout: "" },
2419+
[GIT_MERGE_BASE_MAIN_HEAD_KEY]: { stdout: "abc123\n" },
2420+
},
2421+
},
2422+
);
2423+
2424+
const output = parseFakeCrabboxOutput(result);
2425+
const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
2426+
expect(result.status).toBe(0);
2427+
expect(remoteCommand).toContain(remoteChangedGateFetch);
2428+
expectGroupedShellCommand(remoteCommand, `${remoteChangedGateExport} ${shellScript}`);
2429+
});
2430+
24102431
it("preserves sparse changed-gate Git bootstrap for assignment-prefix command substitutions", () => {
24112432
const shellScript = "TOOL_ROOT=$(pwd) pnpm check:changed";
24122433
const result = runWrapper(
@@ -2469,9 +2490,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
24692490
expect(result.status).toBe(0);
24702491
expect(remoteCommand).toContain("git init -q");
24712492
expect(remoteCommand).toContain(remoteChangedGateFetch);
2472-
expect(remoteCommand).toContain(
2473-
`&& export OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1; ${shellScript}`,
2474-
);
2493+
expect(remoteCommand).toContain(`&& export ${remoteChangedGateEnvPrefix}; ${shellScript}`);
24752494
});
24762495

24772496
it("preserves sparse changed-gate Git bootstrap for shell option values before -c", () => {
@@ -2933,7 +2952,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
29332952
expect(output.args.filter((arg) => arg === "--shell")).toHaveLength(1);
29342953
expect(remoteCommand).toContain(remoteChangedGateFetch);
29352954
expect(remoteCommand).toMatch(
2936-
/&& export OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1; env CI=1 pnpm check:changed$/u,
2955+
/&& export OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 CI=1; env CI=1 pnpm check:changed$/u,
29372956
);
29382957
});
29392958

0 commit comments

Comments
 (0)