Skip to content

Commit 600df9e

Browse files
fix: omit empty router target branch
1 parent 73464f7 commit 600df9e

3 files changed

Lines changed: 35 additions & 3 deletions

File tree

‎.github/workflows/repair-comment-router.yml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,15 @@ jobs:
201201
args=(
202202
--write-report
203203
--repo "$target_repo"
204-
--target-branch "$target_branch"
205204
--lookback-minutes "$lookback_minutes"
206205
--max-comments "$max_comments"
207206
--runner "$runner"
208207
--execution-runner "$execution_runner"
209208
--wait-for-capacity
210209
)
210+
if [ -n "$target_branch" ]; then
211+
args+=(--target-branch "$target_branch")
212+
fi
211213
if [ -n "$since" ]; then
212214
args+=(--since "$since")
213215
fi
@@ -287,13 +289,15 @@ jobs:
287289
args=(
288290
--write-report
289291
--repo "$target_repo"
290-
--target-branch "$target_branch"
291292
--lookback-minutes "$lookback_minutes"
292293
--max-comments "$max_comments"
293294
--runner "$runner"
294295
--execution-runner "$execution_runner"
295296
--wait-for-capacity
296297
)
298+
if [ -n "$target_branch" ]; then
299+
args+=(--target-branch "$target_branch")
300+
fi
297301
if [ -n "$since" ]; then
298302
args+=(--since "$since")
299303
fi

‎test/repair/comment-router-config.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,24 @@ test("comment router config preserves target branch from dispatch args", () => {
1414
assert.equal(config.targetRepo, "openclaw/example");
1515
assert.equal(config.targetBranch, "master");
1616
});
17+
18+
test("comment router config omits target branch by default", () => {
19+
const originalTargetBranch = process.env.CLAWSWEEPER_TARGET_BRANCH;
20+
delete process.env.CLAWSWEEPER_TARGET_BRANCH;
21+
try {
22+
const config = readCommentRouterConfig({
23+
repo: "openclaw/example",
24+
"repair-repo": "openclaw/clawsweeper",
25+
"review-repo": "openclaw/clawsweeper",
26+
});
27+
28+
assert.equal(config.targetRepo, "openclaw/example");
29+
assert.equal(config.targetBranch, "");
30+
} finally {
31+
if (originalTargetBranch === undefined) {
32+
delete process.env.CLAWSWEEPER_TARGET_BRANCH;
33+
} else {
34+
process.env.CLAWSWEEPER_TARGET_BRANCH = originalTargetBranch;
35+
}
36+
}
37+
});

‎test/repair/workflow-sparse-checkout.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,14 @@ test("repair comment router workflow preserves repository dispatch target branch
5252
workflow,
5353
/target_branch="\$\{\{ github\.event\.client_payload\.target_branch \|\| '' \}\}"/,
5454
);
55-
assert.match(workflow, /--target-branch "\$target_branch"/);
55+
assert.equal(
56+
[
57+
...workflow.matchAll(
58+
/if \[ -n "\$target_branch" \]; then\n\s+args\+=\(--target-branch "\$target_branch"\)\n\s+fi/g,
59+
),
60+
].length,
61+
2,
62+
);
5663
});
5764

5865
test("sweep workflow preserves workflow dispatch target branch", () => {

0 commit comments

Comments
 (0)