Skip to content

Commit c6c9a1a

Browse files
Update distribution (#210)
Co-authored-by: peter-evans <[email protected]>
1 parent ce3fa35 commit c6c9a1a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

dist/index.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,17 @@ function appendSeparatorTo(body, separator) {
128128
return body;
129129
}
130130
}
131+
function truncateBody(body) {
132+
// 65536 characters is the maximum allowed for issue comments.
133+
if (body.length > 65536) {
134+
core.warning(`Comment body is too long. Truncating to 65536 characters.`);
135+
return body.substring(0, 65536);
136+
}
137+
return body;
138+
}
131139
function createComment(octokit, owner, repo, issueNumber, body) {
132140
return __awaiter(this, void 0, void 0, function* () {
133-
// 65536 characters is the maximum allowed for issue comments.
134-
if (body.length > 65536) {
135-
core.warning(`Comment body is too long. Truncating to 65536 characters.`);
136-
body = body.substring(0, 65536);
137-
}
141+
body = truncateBody(body);
138142
const { data: comment } = yield octokit.rest.issues.createComment({
139143
owner: owner,
140144
repo: repo,
@@ -158,7 +162,7 @@ function updateComment(octokit, owner, repo, commentId, body, editMode, appendSe
158162
});
159163
commentBody = appendSeparatorTo(comment.body ? comment.body : '', appendSeparator);
160164
}
161-
commentBody = commentBody + body;
165+
commentBody = truncateBody(commentBody + body);
162166
core.debug(`Comment body: ${commentBody}`);
163167
yield octokit.rest.issues.updateComment({
164168
owner: owner,

0 commit comments

Comments
 (0)