Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/clawsweeper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18047,6 +18047,8 @@ async function applyDecisionsCommand(args: Args): Promise<void> {
} catch (error) {
const detail = error instanceof Error ? error.message : String(error);
const reason = `invalid maintainer_decision: ${detail}`;
markdown = replaceFrontMatterValue(markdown, "apply_checked_at", new Date().toISOString());
if (!dryRun) writeFileSync(path, markdown, "utf8");
results.push({ number, action: "kept_open", reason });
processedCount += 1;
maybeLogProgress(`skipped #${number}: ${reason}`);
Expand Down
35 changes: 34 additions & 1 deletion test/clawsweeper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,24 +446,57 @@ test("apply-decisions makes no GitHub mutation for malformed maintainer decision
implementedCloseReport({ maintainer_decision: "{" }),
"utf8",
);
writeFileSync(
join(itemsDir, "322.md"),
implementedCloseReport({ number: 322, maintainer_decision: "{" }),
"utf8",
);

const ghMock = `
console.error("malformed maintainer decision reached GitHub");
process.exit(1);
`;
withMockGh(root, ghMock, () => {
runApplyDecisionsForTest({ itemsDir, closedDir, plansDir, reportPath });
runApplyDecisionsForTest({
itemsDir,
closedDir,
plansDir,
reportPath,
extraArgs: ["--processed-limit", "1"],
});
});

assert.equal(existsSync(join(itemsDir, "321.md")), true);
assert.equal(existsSync(join(closedDir, "321.md")), false);
const firstUpdatedReport = readFileSync(join(itemsDir, "321.md"), "utf8");
assert.match(firstUpdatedReport, /^apply_checked_at: /m);
assert.doesNotMatch(readFileSync(join(itemsDir, "322.md"), "utf8"), /^apply_checked_at: /m);
assert.deepEqual(JSON.parse(readFileSync(reportPath, "utf8")), [
{
number: 321,
action: "kept_open",
reason: "invalid maintainer_decision: maintainer_decision must contain valid JSON",
},
]);

withMockGh(root, ghMock, () => {
runApplyDecisionsForTest({
itemsDir,
closedDir,
plansDir,
reportPath,
extraArgs: ["--processed-limit", "1"],
});
});

assert.match(readFileSync(join(itemsDir, "322.md"), "utf8"), /^apply_checked_at: /m);
assert.deepEqual(JSON.parse(readFileSync(reportPath, "utf8")), [
{
number: 322,
action: "kept_open",
reason: "invalid maintainer_decision: maintainer_decision must contain valid JSON",
},
]);
} finally {
rmSync(root, { recursive: true, force: true });
}
Expand Down