From db31a1634c1e221e644b6ab45531e9b1b31a03fd Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Wed, 8 Jan 2025 17:37:30 +0530 Subject: [PATCH] fix(gitlab): truncate comment (#33348) --- lib/modules/platform/gitlab/index.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/modules/platform/gitlab/index.ts b/lib/modules/platform/gitlab/index.ts index 2460b206d92de0..1010f448cdc7f1 100644 --- a/lib/modules/platform/gitlab/index.ts +++ b/lib/modules/platform/gitlab/index.ts @@ -1361,9 +1361,12 @@ export async function ensureComment({ if (topic) { logger.debug(`Ensuring comment "${massagedTopic!}" in #${number}`); body = `### ${topic}\n\n${sanitizedContent}`; - body = body - .replace(regEx(/Pull Request/g), 'Merge Request') - .replace(regEx(/PR/g), 'MR'); + body = smartTruncate( + body + .replace(regEx(/Pull Request/g), 'Merge Request') + .replace(regEx(/PR/g), 'MR'), + maxBodyLength(), + ); comments.forEach((comment: { body: string; id: number }) => { if (comment.body.startsWith(`### ${massagedTopic!}\n\n`)) { commentId = comment.id; @@ -1372,7 +1375,7 @@ export async function ensureComment({ }); } else { logger.debug(`Ensuring content-only comment in #${number}`); - body = `${sanitizedContent}`; + body = smartTruncate(`${sanitizedContent}`, maxBodyLength()); comments.forEach((comment: { body: string; id: number }) => { if (comment.body === body) { commentId = comment.id;