Skip to content

Commit 64dd23e

Browse files
committed
Truncate issue comments
1 parent 61b749a commit 64dd23e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/utils/gitUtils.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,16 @@ export async function createIssue(postResult: boolean, title: string, bodyChunks
137137
const issueNumber = created.data.number;
138138
console.log(`Created issue #${issueNumber}: ${created.data.html_url}`);
139139

140+
const maxCommentLength = 65535;
141+
const tooLongFooter = `\n\nThis comment was too long to display in full; see the build artifact for the full details.`;
142+
140143
for (const comment of additionalComments) {
141-
await kit.issues.createComment({ issue_number: issueNumber, ...comment });
144+
let body = comment.body;
145+
if (body.length > maxCommentLength) {
146+
body = body.slice(0, maxCommentLength - tooLongFooter.length) + tooLongFooter;
147+
}
148+
149+
await kit.issues.createComment({ issue_number: issueNumber, ...comment, body });
142150
}
143151

144152
if (!sawNewErrors) {

0 commit comments

Comments
 (0)