mirror of
https://github.com/peter-evans/create-or-update-comment.git
synced 2025-01-18 19:22:44 +08:00
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:
parent
d85800fae5
commit
23ff15729e
3
dist/index.js
vendored
3
dist/index.js
vendored
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user