Skip to content

Commit 2106203

Browse files
fix: use fenced code blocks for multi-line error messages in PR comments
Co-Authored-By: Niels Swimberghe <3382717+Swimburger@users.noreply.github.com>
1 parent 3fe89d5 commit 2106203

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

dist/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39703,10 +39703,10 @@ async function pushWithFallback(branchName, owner, repo, octokit) {
3970339703
`- Merge or close this PR so the next run creates a fresh one, or\n` +
3970439704
`- Manually rebase this branch on \`${github.context.ref.replace("refs/heads/", "")}\` and re-run the workflow.`;
3970539705
if (errorMsg) {
39706-
commentBody += `\n\n**${errorLabel}:** \`${errorMsg}\``;
39706+
commentBody += `\n\n**${errorLabel}:**\n\`\`\`\n${errorMsg}\n\`\`\``;
3970739707
}
3970839708
if (abortErrorMsg) {
39709-
commentBody += `\n**Rebase abort error:** \`${abortErrorMsg}\` — the working tree may be in an unexpected state.`;
39709+
commentBody += `\n\n**Rebase abort error:**\n\`\`\`\n${abortErrorMsg}\n\`\`\`\n— the working tree may be in an unexpected state.`;
3971039710
}
3971139711
await octokit.rest.issues.createComment({
3971239712
owner,

src/sync.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ describe("updateFromSourceSpec", () => {
376376
expect(commentCall.body).toContain("Sync failed");
377377
expect(commentCall.body).toContain("merge conflicts");
378378
expect(commentCall.body).toContain("Rebase error:");
379+
expect(commentCall.body).toContain("```");
379380
expect(commentCall.body).toContain("CONFLICT (content)");
380381
expect(commentCall.body).toContain("could not apply");
381382

@@ -553,6 +554,7 @@ describe("updateFromSourceSpec", () => {
553554

554555
const commentCall = mockIssuesCreateComment.mock.calls[0][0];
555556
expect(commentCall.body).toContain("Rebase error:");
557+
expect(commentCall.body).toContain("```");
556558
expect(commentCall.body).toContain("merge conflict");
557559
expect(commentCall.body).toContain("Rebase abort error:");
558560
expect(commentCall.body).toContain("no rebase in progress");

src/sync.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,10 +611,10 @@ async function pushWithFallback(
611611
`- Manually rebase this branch on \`${github.context.ref.replace("refs/heads/", "")}\` and re-run the workflow.`;
612612

613613
if (errorMsg) {
614-
commentBody += `\n\n**${errorLabel}:** \`${errorMsg}\``;
614+
commentBody += `\n\n**${errorLabel}:**\n\`\`\`\n${errorMsg}\n\`\`\``;
615615
}
616616
if (abortErrorMsg) {
617-
commentBody += `\n**Rebase abort error:** \`${abortErrorMsg}\` — the working tree may be in an unexpected state.`;
617+
commentBody += `\n\n**Rebase abort error:**\n\`\`\`\n${abortErrorMsg}\n\`\`\`\n— the working tree may be in an unexpected state.`;
618618
}
619619

620620
await octokit.rest.issues.createComment({

0 commit comments

Comments
 (0)