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 <ethanmdavidson@gmail.com>
This commit is contained in:
Peter Evans 2023-10-20 00:24:24 +09:00 committed by GitHub
parent d85800fae5
commit 23ff15729e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

3
dist/index.js vendored
View File

@ -130,9 +130,10 @@ function appendSeparatorTo(body, separator) {
} }
function truncateBody(body) { function truncateBody(body) {
// 65536 characters is the maximum allowed for issue comments. // 65536 characters is the maximum allowed for issue comments.
const truncateWarning = '...*[Comment body truncated]*';
if (body.length > 65536) { if (body.length > 65536) {
core.warning(`Comment body is too long. Truncating to 65536 characters.`); 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; return body;
} }

View File

@ -120,9 +120,10 @@ function appendSeparatorTo(body: string, separator: string): string {
function truncateBody(body: string) { function truncateBody(body: string) {
// 65536 characters is the maximum allowed for issue comments. // 65536 characters is the maximum allowed for issue comments.
const truncateWarning = '...*[Comment body truncated]*'
if (body.length > 65536) { if (body.length > 65536) {
core.warning(`Comment body is too long. Truncating to 65536 characters.`) 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 return body
} }