Skip to content

Commit 23ff157

Browse files
Add truncate warning to body of comment (peter-evans#272)
* Add truncate warning to body of comment (peter-evans#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>
1 parent d85800f commit 23ff157

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

dist/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ function appendSeparatorTo(body, separator) {
130130
}
131131
function truncateBody(body) {
132132
// 65536 characters is the maximum allowed for issue comments.
133+
const truncateWarning = '...*[Comment body truncated]*';
133134
if (body.length > 65536) {
134135
core.warning(`Comment body is too long. Truncating to 65536 characters.`);
135-
return body.substring(0, 65536);
136+
return body.substring(0, 65536 - truncateWarning.length) + truncateWarning;
136137
}
137138
return body;
138139
}

src/create-or-update-comment.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ function appendSeparatorTo(body: string, separator: string): string {
120120

121121
function truncateBody(body: string) {
122122
// 65536 characters is the maximum allowed for issue comments.
123+
const truncateWarning = '...*[Comment body truncated]*'
123124
if (body.length > 65536) {
124125
core.warning(`Comment body is too long. Truncating to 65536 characters.`)
125-
return body.substring(0, 65536)
126+
return body.substring(0, 65536 - truncateWarning.length) + truncateWarning
126127
}
127128
return body
128129
}

0 commit comments

Comments
 (0)