diff --git a/lib/platform/gitlab/index.spec.ts b/lib/platform/gitlab/index.spec.ts index 9831c459db8dd3b1df8271772d19eeffd55540e0..d2d1182775978f4b0f2044eeef5ca967670ad7bf 100644 --- a/lib/platform/gitlab/index.spec.ts +++ b/lib/platform/gitlab/index.spec.ts @@ -1512,6 +1512,7 @@ describe('platform/gitlab', () => { expect(httpMock.getTrace()).toMatchSnapshot(); }); }); + const prBody = `https://github.com/foo/bar/issues/5 plus also [a link](https://github.com/foo/bar/issues/5 Pull Requests are the best, here are some PRs. @@ -1522,11 +1523,28 @@ These updates have all been created already. Click a checkbox below to force a r - [ ] <!-- rebase-branch=renovate/major-got-packages -->[build(deps): update got packages (major)](../pull/2433) (\`gh-got\`, \`gl-got\`, \`got\`) `; + describe('massageMarkdown(input)', () => { - it('returns updated pr body', () => { + it('returns updated pr body', async () => { + jest.mock('../utils/pr-body'); + const { smartTruncate } = require('../utils/pr-body'); + + await initFakePlatform('13.4.0'); expect(gitlab.massageMarkdown(prBody)).toMatchSnapshot(); + expect(smartTruncate).not.toHaveBeenCalled(); + }); + + it('truncates description if too low API version', async () => { + jest.mock('../utils/pr-body'); + const { smartTruncate } = require('../utils/pr-body'); + + await initFakePlatform('13.3.0'); + gitlab.massageMarkdown(prBody); + expect(smartTruncate).toHaveBeenCalledTimes(1); + expect(smartTruncate).toHaveBeenCalledWith(expect.any(String), 25000); }); }); + describe('getVulnerabilityAlerts()', () => { it('returns empty', async () => { const res = await gitlab.getVulnerabilityAlerts(); diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index 02976cf76a110f9bbf5db523af24cf36cf729f9f..8ea18a0cd42b3bcb660ab2724113365e76891fdc 100755 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -608,13 +608,21 @@ export async function mergePr(iid: number): Promise<boolean> { } export function massageMarkdown(input: string): string { - return smartTruncate( - input - .replace(/Pull Request/g, 'Merge Request') - .replace(/PR/g, 'MR') - .replace(/\]\(\.\.\/pull\//g, '](!'), - 25000 // TODO: increase it once https://gitlab.com/gitlab-org/gitlab/-/issues/217483 is closed - ); + let desc = input + .replace(/Pull Request/g, 'Merge Request') + .replace(/PR/g, 'MR') + .replace(/\]\(\.\.\/pull\//g, '](!'); + + if (lt(defaults.version, '13.4.0')) { + logger.debug( + { version: defaults.version }, + 'GitLab versions earlier than 13.4 have issues with long descriptions, truncating to 25K characters' + ); + + desc = smartTruncate(desc, 25000); + } + + return desc; } // Branch