MCPcopy
hub / github.com/openclaw/clawsweeper / readReport

Function readReport

src/repair/commit-finding-intake.ts:400–428  ·  view source on GitHub ↗
({ reportRepo, reportPath }: LooseRecord)

Source from the content-addressed store, hash-verified

398}
399
400function readReport({ reportRepo, reportPath }: LooseRecord): CommitFindingReportReadResult {
401 const local = args["report-file"] ?? args.report_file;
402 if (typeof local === "string") {
403 return { ok: true, markdown: fs.readFileSync(path.resolve(local), "utf8") };
404 }
405 try {
406 const content = ghText([
407 "api",
408 `repos/${reportRepo}/contents/${reportPath}`,
409 "--method",
410 "GET",
411 "-f",
412 "ref=main",
413 "--jq",
414 ".content",
415 ]);
416 return {
417 ok: true,
418 markdown: Buffer.from(content.replace(/\s+/g, ""), "base64").toString("utf8"),
419 };
420 } catch (error) {
421 const message = ghErrorText(error) || `failed to fetch ${reportRepo}:${reportPath}`;
422 if (isMissingGithubContentError(message)) {
423 return missingCommitFindingReport(String(reportRepo), String(reportPath));
424 }
425 die(message);
426 throw new Error(message);
427 }
428}
429
430function parseCommitReport(markdown: string) {
431 const match = markdown.match(/^---\n([\s\S]*?)\n---\n?/);

Callers 1

prepareFunction · 0.70

Calls 5

ghTextFunction · 0.85
ghErrorTextFunction · 0.70
dieFunction · 0.70

Tested by

no test coverage detected