Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gitlab): smart truncate comments #30580

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/modules/platform/gitlab/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,7 @@ export async function ensureComment({
body = body
.replace(regEx(/Pull Request/g), 'Merge Request')
.replace(regEx(/PR/g), 'MR');
body = smartTruncate(body, maxBodyLength());
Comment on lines 1391 to +1394
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
body = body
.replace(regEx(/Pull Request/g), 'Merge Request')
.replace(regEx(/PR/g), 'MR');
body = smartTruncate(body, maxBodyLength());
body = smartTruncate(body
.replace(regEx(/Pull Request/g), 'Merge Request')
.replace(regEx(/PR/g), maxBodyLength());

needs prettifying

comments.forEach((comment: { body: string; id: number }) => {
if (comment.body.startsWith(`### ${massagedTopic!}\n\n`)) {
commentId = comment.id;
Expand All @@ -1400,13 +1401,15 @@ export async function ensureComment({
} else {
logger.debug(`Ensuring content-only comment in #${number}`);
body = `${sanitizedContent}`;
body = smartTruncate(body, maxBodyLength());
Comment on lines 1403 to +1404
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
body = `${sanitizedContent}`;
body = smartTruncate(body, maxBodyLength());
body = smartTruncate(`${sanitizedContent}`, maxBodyLength());

comments.forEach((comment: { body: string; id: number }) => {
if (comment.body === body) {
commentId = comment.id;
commentNeedsUpdating = false;
}
});
}

if (!commentId) {
await addComment(number, body);
logger.debug(
Expand Down