diff --git a/lib/modules/platform/gitlab/index.spec.ts b/lib/modules/platform/gitlab/index.spec.ts index 03157d7b30ed0896c972d85f8a897fcd4ce56db1..0fca92571e72a2c8b965216e30d4ec3f25b2cf88 100644 --- a/lib/modules/platform/gitlab/index.spec.ts +++ b/lib/modules/platform/gitlab/index.spec.ts @@ -2467,6 +2467,19 @@ These updates have all been created already. Click a checkbox below to force a r ).toBe("The source contains 'Ruby' at: 2.7.6.219"); }); + it('replaces PR with MR including pluralization', () => { + expect( + gitlab.massageMarkdown( + 'A Pull Request is a PR, multiple Pull Requests are PRs.' + ) + ).toBe('A Merge Request is a MR, multiple Merge Requests are MRs.'); + }); + + it('avoids false positives when replacing PR with MR', () => { + const nothingToReplace = 'PROCESSING APPROPRIATE SUPPRESS NOPR'; + expect(gitlab.massageMarkdown(nothingToReplace)).toBe(nothingToReplace); + }); + it('returns updated pr body', async () => { jest.mock('../utils/pr-body'); const { smartTruncate } = require('../utils/pr-body'); diff --git a/lib/modules/platform/gitlab/index.ts b/lib/modules/platform/gitlab/index.ts index addc0dc1f36e7c8b38113dceb127401c8dc6c836..24cbda8fbc2a6ed67a2e4aedc26a4e8b3ccfd646 100644 --- a/lib/modules/platform/gitlab/index.ts +++ b/lib/modules/platform/gitlab/index.ts @@ -783,7 +783,8 @@ export async function mergePr({ id }: MergePRConfig): Promise<boolean> { export function massageMarkdown(input: string): string { let desc = input .replace(regEx(/Pull Request/g), 'Merge Request') - .replace(regEx(/PR/g), 'MR') + .replace(regEx(/\bPR\b/g), 'MR') + .replace(regEx(/\bPRs\b/g), 'MRs') .replace(regEx(/\]\(\.\.\/pull\//g), '](!') // Strip unicode null characters as GitLab markdown does not permit them .replace(regEx(/\u0000/g), ''); // eslint-disable-line no-control-regex