( number: number, lens: string, headSha: string, body: string, )
| 7558 | } |
| 7559 | |
| 7560 | function postOrUpdateVisualComment( |
| 7561 | number: number, |
| 7562 | lens: string, |
| 7563 | headSha: string, |
| 7564 | body: string, |
| 7565 | ): void { |
| 7566 | const marker = visualCommentMarker(number, lens, headSha); |
| 7567 | const existing = ghPaged<unknown>(`repos/${targetRepo()}/issues/${number}/comments?per_page=100`) |
| 7568 | .map(asRecord) |
| 7569 | .find((comment) => typeof comment.body === "string" && comment.body.includes(marker)); |
| 7570 | const payload = writeCommentPayload(number, body); |
| 7571 | const existingId = |
| 7572 | typeof existing?.id === "number" || typeof existing?.id === "string" ? existing.id : null; |
| 7573 | if (existingId) { |
| 7574 | ghWithRetry([ |
| 7575 | "api", |
| 7576 | `repos/${targetRepo()}/issues/comments/${existingId}`, |
| 7577 | "--method", |
| 7578 | "PATCH", |
| 7579 | "--input", |
| 7580 | payload, |
| 7581 | ]); |
| 7582 | return; |
| 7583 | } |
| 7584 | ghWithRetry([ |
| 7585 | "api", |
| 7586 | `repos/${targetRepo()}/issues/${number}/comments`, |
| 7587 | "--method", |
| 7588 | "POST", |
| 7589 | "--input", |
| 7590 | payload, |
| 7591 | ]); |
| 7592 | } |
| 7593 | |
| 7594 | function closeReasonText(reason: CloseReason): string { |
| 7595 | switch (reason) { |
no test coverage detected