From 23ff15729ef2fc348714a3bb66d2f655ca9066f2 Mon Sep 17 00:00:00 2001 From: Peter Evans <18365890+peter-evans@users.noreply.github.com> Date: Fri, 20 Oct 2023 00:24:24 +0900 Subject: [PATCH] Add truncate warning to body of comment (#272) * Add truncate warning to body of comment (#271) * add truncate warning to body of comment * tweak warning Co-authored-by: Peter Evans <18365890+peter-evans@users.noreply.github.com> --------- Co-authored-by: Peter Evans <18365890+peter-evans@users.noreply.github.com> * lint fixes * update dist --------- Co-authored-by: Ethan Davidson --- dist/index.js | 3 ++- src/create-or-update-comment.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index cb31a1c4..f96c55c0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -130,9 +130,10 @@ function appendSeparatorTo(body, separator) { } function truncateBody(body) { // 65536 characters is the maximum allowed for issue comments. + const truncateWarning = '...*[Comment body truncated]*'; if (body.length > 65536) { core.warning(`Comment body is too long. Truncating to 65536 characters.`); - return body.substring(0, 65536); + return body.substring(0, 65536 - truncateWarning.length) + truncateWarning; } return body; } diff --git a/src/create-or-update-comment.ts b/src/create-or-update-comment.ts index 80880adf..f6be7b93 100644 --- a/src/create-or-update-comment.ts +++ b/src/create-or-update-comment.ts @@ -120,9 +120,10 @@ function appendSeparatorTo(body: string, separator: string): string { function truncateBody(body: string) { // 65536 characters is the maximum allowed for issue comments. + const truncateWarning = '...*[Comment body truncated]*' if (body.length > 65536) { core.warning(`Comment body is too long. Truncating to 65536 characters.`) - return body.substring(0, 65536) + return body.substring(0, 65536 - truncateWarning.length) + truncateWarning } return body }