Skip to content

Commit 5affc00

Browse files
committed
Clarify offline default branch planning
1 parent a6ee02e commit 5affc00

2 files changed

Lines changed: 48 additions & 3 deletions

File tree

‎src/repair/plan-cluster.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,10 +732,10 @@ function fetchDefaultBranchName(repo: string) {
732732

733733
function offlineMainBranch(repo: string) {
734734
return {
735-
name: "main",
735+
name: "unknown",
736736
sha: null,
737-
url: `https://github.com/${repo}/tree/main`,
738-
note: "offline mode did not fetch current main",
737+
url: `https://github.com/${repo}`,
738+
note: "offline mode did not fetch current default branch",
739739
};
740740
}
741741

‎test/repair/plan-cluster.test.ts‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,51 @@ test("plan-cluster hydrates the repository default branch instead of hard-coding
9797
});
9898
});
9999

100+
test("plan-cluster offline mode does not pretend the default branch is main", () => {
101+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "clawsweeper-plan-offline-default-"));
102+
const jobPath = path.join(tmp, "job.md");
103+
const runDir = path.join(tmp, "run");
104+
105+
fs.writeFileSync(
106+
jobPath,
107+
[
108+
"---",
109+
"repo: openclaw/openclaw",
110+
"cluster_id: issue-implementation-openclaw-openclaw-74134",
111+
"mode: autonomous",
112+
"allowed_actions:",
113+
" - comment",
114+
"canonical:",
115+
" - #74134",
116+
"candidates:",
117+
" - #74134",
118+
"allow_fix_pr: false",
119+
"security_policy: central_security_only",
120+
"security_sensitive: false",
121+
"---",
122+
"Plan this item.",
123+
"",
124+
].join("\n"),
125+
);
126+
127+
execFileSync(
128+
process.execPath,
129+
["dist/repair/plan-cluster.js", jobPath, "--run-dir", runDir, "--offline"],
130+
{
131+
cwd: process.cwd(),
132+
stdio: "pipe",
133+
},
134+
);
135+
136+
const clusterPlan = JSON.parse(fs.readFileSync(path.join(runDir, "cluster-plan.json"), "utf8"));
137+
assert.deepEqual(clusterPlan.main, {
138+
name: "unknown",
139+
sha: null,
140+
url: "https://github.com/openclaw/openclaw",
141+
note: "offline mode did not fetch current default branch",
142+
});
143+
});
144+
100145
test("plan-cluster allows security repair for adopted PR autofix jobs", () => {
101146
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "clawsweeper-plan-security-autofix-"));
102147
const jobPath = path.join(tmp, "job.md");

0 commit comments

Comments
 (0)