diff --git a/lib/platform/azure/__snapshots__/index.spec.ts.snap b/lib/platform/azure/__snapshots__/index.spec.ts.snap index 639d7254a5e39ed1e6616e5ae8bcfca94844688c..8b419d878c3630fb12f40d4141427a3a94bd82bc 100644 --- a/lib/platform/azure/__snapshots__/index.spec.ts.snap +++ b/lib/platform/azure/__snapshots__/index.spec.ts.snap @@ -199,7 +199,7 @@ Object { } `; -exports[`platform/azure getPrBody(input) returns updated pr body 1`] = `"https://github.com/foo/bar/issues/5 plus also [a link](https://github.com/foo/bar/issues/5)"`; +exports[`platform/azure massageMarkdown(input) returns updated pr body 1`] = `"https://github.com/foo/bar/issues/5 plus also [a link](https://github.com/foo/bar/issues/5)"`; exports[`platform/azure getRepos() should return an array of repos 1`] = ` Array [ diff --git a/lib/platform/azure/index.spec.ts b/lib/platform/azure/index.spec.ts index 5151d362a4b2ba9f900025fc51a81fdad2490282..9dc59672a61761bd3454bd23219ab9fdd9c9c4e2 100644 --- a/lib/platform/azure/index.spec.ts +++ b/lib/platform/azure/index.spec.ts @@ -938,11 +938,11 @@ describe('platform/azure', () => { }); }); - describe('getPrBody(input)', () => { + describe('massageMarkdown(input)', () => { it('returns updated pr body', () => { const input = '<details>https://github.com/foo/bar/issues/5 plus also [a link](https://github.com/foo/bar/issues/5)'; - expect(azure.getPrBody(input)).toMatchSnapshot(); + expect(azure.massageMarkdown(input)).toMatchSnapshot(); }); }); diff --git a/lib/platform/azure/index.ts b/lib/platform/azure/index.ts index 4b11286c7c5499e8c80443be591d9f0c6940b34d..59ce57dff9889c74915645ce6cdf06f2fdcca745 100644 --- a/lib/platform/azure/index.ts +++ b/lib/platform/azure/index.ts @@ -654,7 +654,7 @@ export async function mergePr( } } -export function getPrBody(input: string): string { +export function massageMarkdown(input: string): string { // Remove any HTML we use return smartTruncate(input, 4000) .replace( diff --git a/lib/platform/bitbucket-server/__snapshots__/index.spec.ts.snap b/lib/platform/bitbucket-server/__snapshots__/index.spec.ts.snap index 1f3af18f51564d1abc46d2051597c12fda212d96..95196af6884dcfe87d4fb026a30f56c10006de6c 100644 --- a/lib/platform/bitbucket-server/__snapshots__/index.spec.ts.snap +++ b/lib/platform/bitbucket-server/__snapshots__/index.spec.ts.snap @@ -2310,9 +2310,9 @@ Array [ exports[`platform/bitbucket-server/index endpoint with no path getPr() returns null for no prNo 1`] = `Array []`; -exports[`platform/bitbucket-server/index endpoint with no path getPrBody() returns diff files 1`] = `"**foo**bartext"`; +exports[`platform/bitbucket-server/index endpoint with no path massageMarkdown() returns diff files 1`] = `"**foo**bartext"`; -exports[`platform/bitbucket-server/index endpoint with no path getPrBody() sanitizes HTML comments in the body 1`] = ` +exports[`platform/bitbucket-server/index endpoint with no path massageMarkdown() sanitizes HTML comments in the body 1`] = ` "--- - [ ] If you want to rebase/retry this PR, check this box @@ -6400,9 +6400,9 @@ Array [ exports[`platform/bitbucket-server/index endpoint with path getPr() returns null for no prNo 1`] = `Array []`; -exports[`platform/bitbucket-server/index endpoint with path getPrBody() returns diff files 1`] = `"**foo**bartext"`; +exports[`platform/bitbucket-server/index endpoint with path massageMarkdown() returns diff files 1`] = `"**foo**bartext"`; -exports[`platform/bitbucket-server/index endpoint with path getPrBody() sanitizes HTML comments in the body 1`] = ` +exports[`platform/bitbucket-server/index endpoint with path massageMarkdown() sanitizes HTML comments in the body 1`] = ` "--- - [ ] If you want to rebase/retry this PR, check this box diff --git a/lib/platform/bitbucket-server/index.spec.ts b/lib/platform/bitbucket-server/index.spec.ts index aac0a284782968b0a91ca08dadc849f3c3d2da50..f2f29b3dff4ad13cca3ae3b183249a83d6a8e859 100644 --- a/lib/platform/bitbucket-server/index.spec.ts +++ b/lib/platform/bitbucket-server/index.spec.ts @@ -1698,17 +1698,17 @@ describe(getName(__filename), () => { }); }); - describe('getPrBody()', () => { + describe('massageMarkdown()', () => { it('returns diff files', () => { expect( - bitbucket.getPrBody( + bitbucket.massageMarkdown( '<details><summary>foo</summary>bar</details>text<details>' ) ).toMatchSnapshot(); }); it('sanitizes HTML comments in the body', () => { - const prBody = bitbucket.getPrBody(`--- + const prBody = bitbucket.massageMarkdown(`--- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box - [ ] <!-- recreate-branch=renovate/docker-renovate-renovate-16.x --><a href="/some/link">Update renovate/renovate to 16.1.2</a> diff --git a/lib/platform/bitbucket-server/index.ts b/lib/platform/bitbucket-server/index.ts index bb07c4e1cfdd7de2e1116b6b320ec02d01dd70c1..8b785124b1dd2b24995a4b0ba876fe2ec9f89968 100644 --- a/lib/platform/bitbucket-server/index.ts +++ b/lib/platform/bitbucket-server/index.ts @@ -985,8 +985,8 @@ export async function mergePr( return true; } -export function getPrBody(input: string): string { - logger.debug(`getPrBody(${input.split('\n')[0]})`); +export function massageMarkdown(input: string): string { + logger.debug(`massageMarkdown(${input.split('\n')[0]})`); // Remove any HTML we use return smartTruncate(input, 30000) .replace( diff --git a/lib/platform/bitbucket/__snapshots__/index.spec.ts.snap b/lib/platform/bitbucket/__snapshots__/index.spec.ts.snap index c5ead11ef57ce6b20ad8c5358da7538fd579612e..b39927489581a370a296dfd5d79408382abba28e 100644 --- a/lib/platform/bitbucket/__snapshots__/index.spec.ts.snap +++ b/lib/platform/bitbucket/__snapshots__/index.spec.ts.snap @@ -1040,7 +1040,7 @@ Array [ ] `; -exports[`platform/bitbucket getPrBody() returns diff files 1`] = `"**foo**bartext"`; +exports[`platform/bitbucket massageMarkdown() returns diff files 1`] = `"**foo**bartext"`; exports[`platform/bitbucket getPrList() filters PR list by author 1`] = ` Array [ diff --git a/lib/platform/bitbucket/index.spec.ts b/lib/platform/bitbucket/index.spec.ts index b3363320c87d544069547c19984df2addc8e423b..18ae7caca54b88856a6e41b33c38bf5ac0307dca 100644 --- a/lib/platform/bitbucket/index.spec.ts +++ b/lib/platform/bitbucket/index.spec.ts @@ -726,10 +726,10 @@ describe('platform/bitbucket', () => { }); }); - describe('getPrBody()', () => { + describe('massageMarkdown()', () => { it('returns diff files', () => { expect( - bitbucket.getPrBody( + bitbucket.massageMarkdown( '<details><summary>foo</summary>bar</details>text<details>' ) ).toMatchSnapshot(); diff --git a/lib/platform/bitbucket/index.ts b/lib/platform/bitbucket/index.ts index f0edfd32c8e34dda2ae720915e3da64e15d13cb7..3a45348c40e5b0008cb4f1fe9e6c628f3cdb7534 100644 --- a/lib/platform/bitbucket/index.ts +++ b/lib/platform/bitbucket/index.ts @@ -460,7 +460,7 @@ async function closeIssue(issueNumber: number): Promise<void> { ); } -export function getPrBody(input: string): string { +export function massageMarkdown(input: string): string { // Remove any HTML we use return smartTruncate(input, 50000) .replace( @@ -479,7 +479,7 @@ export async function ensureIssue({ body, }: EnsureIssueConfig): Promise<EnsureIssueResult | null> { logger.debug(`ensureIssue()`); - const description = getPrBody(sanitize(body)); + const description = massageMarkdown(sanitize(body)); /* istanbul ignore if */ if (!config.has_issues) { diff --git a/lib/platform/common.ts b/lib/platform/common.ts index f09ef6ed7761bcc377f4a690e1474499a337442b..886b41f031b8c5f488c61145da13ad19bfd20b4d 100644 --- a/lib/platform/common.ts +++ b/lib/platform/common.ts @@ -152,7 +152,7 @@ export interface Platform { ensureIssue( issueConfig: EnsureIssueConfig ): Promise<EnsureIssueResult | null>; - getPrBody(prBody: string): string; + massageMarkdown(prBody: string): string; updatePr(prConfig: UpdatePrConfig): Promise<void>; mergePr(number: number, branchName: string): Promise<boolean>; addReviewers(number: number, reviewers: string[]): Promise<void>; diff --git a/lib/platform/gitea/index.spec.ts b/lib/platform/gitea/index.spec.ts index 146dda9c666cf9003a25d95ff2ae40a5fa228452..be9ceeafe1e4658f400163fc17c40f39637e0e3f 100644 --- a/lib/platform/gitea/index.spec.ts +++ b/lib/platform/gitea/index.spec.ts @@ -1313,11 +1313,11 @@ describe('platform/gitea', () => { }); }); - describe('getPrBody', () => { + describe('massageMarkdown', () => { it('should truncate body to 1000000 characters', () => { const excessiveBody = '*'.repeat(1000001); - expect(gitea.getPrBody(excessiveBody)).toHaveLength(1000000); + expect(gitea.massageMarkdown(excessiveBody)).toHaveLength(1000000); }); }); diff --git a/lib/platform/gitea/index.ts b/lib/platform/gitea/index.ts index a028bf8ed203b41e0bba1c1120a56213f8bd1ada..7b6dd1f694b92e3fb1975f93e9ce3b07d6f3e6b0 100644 --- a/lib/platform/gitea/index.ts +++ b/lib/platform/gitea/index.ts @@ -800,7 +800,7 @@ const platform: Platform = { } }, - getPrBody(prBody: string): string { + massageMarkdown(prBody: string): string { return smartTruncate(smartLinks(prBody), 1000000); }, @@ -827,7 +827,7 @@ export const { getJsonFile, getIssueList, getPr, - getPrBody, + massageMarkdown, getPrList, getRepoForceRebase, getRepos, diff --git a/lib/platform/github/__snapshots__/index.spec.ts.snap b/lib/platform/github/__snapshots__/index.spec.ts.snap index d51b08c1e0d9d75d3b655d51039cafef8f5cbe03..364f976566650714cfe22337132cc5f573a28ce0 100644 --- a/lib/platform/github/__snapshots__/index.spec.ts.snap +++ b/lib/platform/github/__snapshots__/index.spec.ts.snap @@ -4199,7 +4199,7 @@ Array [ ] `; -exports[`platform/github getPrBody(input) returns not-updated pr body for GHE 1`] = ` +exports[`platform/github massageMarkdown(input) returns not-updated pr body for GHE 1`] = ` Array [ Object { "headers": Object { @@ -4261,7 +4261,7 @@ Array [ ] `; -exports[`platform/github getPrBody(input) returns updated pr body 1`] = `"https://github.com/foo/bar/issues/5 plus also [a link](https://togithub.com/foo/bar/issues/5)"`; +exports[`platform/github massageMarkdown(input) returns updated pr body 1`] = `"https://github.com/foo/bar/issues/5 plus also [a link](https://togithub.com/foo/bar/issues/5)"`; exports[`platform/github getRepoForceRebase should detect repoForceRebase 1`] = ` Array [ diff --git a/lib/platform/github/index.spec.ts b/lib/platform/github/index.spec.ts index 2f35b846cc7adfe0294e05b7c9683a000ec5478c..f0a0c5ae5655b8e3c90a45949173d39125100e2e 100644 --- a/lib/platform/github/index.spec.ts +++ b/lib/platform/github/index.spec.ts @@ -1852,11 +1852,11 @@ describe('platform/github', () => { expect(httpMock.getTrace()).toMatchSnapshot(); }); }); - describe('getPrBody(input)', () => { + describe('massageMarkdown(input)', () => { it('returns updated pr body', () => { const input = 'https://github.com/foo/bar/issues/5 plus also [a link](https://github.com/foo/bar/issues/5)'; - expect(github.getPrBody(input)).toMatchSnapshot(); + expect(github.massageMarkdown(input)).toMatchSnapshot(); }); it('returns not-updated pr body for GHE', async () => { const scope = httpMock @@ -1880,7 +1880,7 @@ describe('platform/github', () => { } as any); const input = 'https://github.com/foo/bar/issues/5 plus also [a link](https://github.com/foo/bar/issues/5)'; - expect(github.getPrBody(input)).toEqual(input); + expect(github.massageMarkdown(input)).toEqual(input); expect(httpMock.getTrace()).toMatchSnapshot(); }); }); diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 0450a4c20f69834d3d2723a20af24e8ee09847a7..5ba50d313dfc5442e3e62db361273b7a805d6eff 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -1574,7 +1574,7 @@ export async function mergePr( return true; } -export function getPrBody(input: string): string { +export function massageMarkdown(input: string): string { if (config.isGhe) { return smartTruncate(input, 60000); } diff --git a/lib/platform/gitlab/__snapshots__/index.spec.ts.snap b/lib/platform/gitlab/__snapshots__/index.spec.ts.snap index 5f12ade0c59813e8f1acc993037e866db3a2107e..2e6a2fd13154eaefd913f36c9a755cb7ef5aeb51 100644 --- a/lib/platform/gitlab/__snapshots__/index.spec.ts.snap +++ b/lib/platform/gitlab/__snapshots__/index.spec.ts.snap @@ -1714,7 +1714,7 @@ Array [ ] `; -exports[`platform/gitlab getPrBody(input) returns updated pr body 1`] = ` +exports[`platform/gitlab massageMarkdown(input) returns updated pr body 1`] = ` "https://github.com/foo/bar/issues/5 plus also [a link](https://github.com/foo/bar/issues/5 Merge Requests are the best, here are some MRs. diff --git a/lib/platform/gitlab/index.spec.ts b/lib/platform/gitlab/index.spec.ts index 04b889d634c1e6af801c0f3ac5df9a0055990d9c..0755bbd7d43beb3e4dc412f38c7e925d05e02a8d 100644 --- a/lib/platform/gitlab/index.spec.ts +++ b/lib/platform/gitlab/index.spec.ts @@ -1364,9 +1364,9 @@ 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('getPrBody(input)', () => { + describe('massageMarkdown(input)', () => { it('returns updated pr body', () => { - expect(gitlab.getPrBody(prBody)).toMatchSnapshot(); + expect(gitlab.massageMarkdown(prBody)).toMatchSnapshot(); }); }); describe('getVulnerabilityAlerts()', () => { diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index b15e6ed790703dc8c9d1c6887fcf1f0564aac881..e3001c99cdd8bbcbc2768bbf59e93e78edda7cee 100755 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -596,7 +596,7 @@ export async function mergePr(iid: number): Promise<boolean> { } } -export function getPrBody(input: string): string { +export function massageMarkdown(input: string): string { return smartTruncate( input .replace(/Pull Request/g, 'Merge Request') @@ -764,7 +764,7 @@ export async function ensureIssue({ body, }: EnsureIssueConfig): Promise<'updated' | 'created' | null> { logger.debug(`ensureIssue()`); - const description = getPrBody(sanitize(body)); + const description = massageMarkdown(sanitize(body)); try { const issueList = await getIssueList(); let issue = issueList.find((i) => i.title === title); diff --git a/lib/workers/branch/index.ts b/lib/workers/branch/index.ts index 25f6bf38243ec908cfe9ef1da65a6e61f8714fc1..1cfa41636e1380be59be7b695370027e777c34c0 100644 --- a/lib/workers/branch/index.ts +++ b/lib/workers/branch/index.ts @@ -658,7 +658,7 @@ export async function processBranch( content += `##### File name: ${error.lockFile}\n\n`; content += `\`\`\`\n${error.stderr}\n\`\`\`\n\n`; }); - content = platform.getPrBody(content); + content = platform.massageMarkdown(content); if ( !( config.suppressNotifications.includes('artifactErrors') || diff --git a/lib/workers/pr/body/index.ts b/lib/workers/pr/body/index.ts index bf94c4f37b32355ad107c344d99d56e740004ec6..c6f1e61a03f625f770cfc6cd79a8ea2a959b93a6 100644 --- a/lib/workers/pr/body/index.ts +++ b/lib/workers/pr/body/index.ts @@ -85,6 +85,6 @@ export async function getPrBody(config: BranchConfig): Promise<string> { let prBody = template.compile(prBodyTemplate, content, false); prBody = prBody.trim(); prBody = prBody.replace(/\n\n\n+/g, '\n\n'); - prBody = platform.getPrBody(prBody); + prBody = platform.massageMarkdown(prBody); return prBody; } diff --git a/lib/workers/pr/index.spec.ts b/lib/workers/pr/index.spec.ts index 028d6b3d617a08ed05b07d525ce8241954e482f0..b8092fc4896e7a471ffcc89d997160812db3f213 100644 --- a/lib/workers/pr/index.spec.ts +++ b/lib/workers/pr/index.spec.ts @@ -201,7 +201,7 @@ describe('workers/pr', () => { displayNumber: 'New Pull Request', } as never); config.upgrades = [config]; - platform.getPrBody = jest.fn((input) => input); + platform.massageMarkdown = jest.fn((input) => input); platform.getBranchPr = jest.fn(); platform.getBranchStatus = jest.fn(); }); diff --git a/lib/workers/pr/index.ts b/lib/workers/pr/index.ts index bb038eefdafbb73a8e770a0d5a0badacfe6891cf..716180c0eae07dd991f244635d4b065de9d6c194 100644 --- a/lib/workers/pr/index.ts +++ b/lib/workers/pr/index.ts @@ -435,7 +435,7 @@ export async function ensurePr( if (config.branchAutomergeFailureMessage === 'branch status error') { content += '\n___\n * Branch has one or more failed status checks'; } - content = platform.getPrBody(content); + content = platform.massageMarkdown(content); logger.debug('Adding branch automerge failure message to PR'); // istanbul ignore if if (getAdminConfig().dryRun) { diff --git a/lib/workers/repository/onboarding/pr/index.spec.ts b/lib/workers/repository/onboarding/pr/index.spec.ts index 6b9e02b4a25fe4bfce423c8bdcee3a9a49b7a7fb..6ddb61ea17017cc99af46c10bfaa32497509dd0c 100644 --- a/lib/workers/repository/onboarding/pr/index.spec.ts +++ b/lib/workers/repository/onboarding/pr/index.spec.ts @@ -29,7 +29,7 @@ describe('workers/repository/onboarding/pr', () => { }; packageFiles = { npm: [{ packageFile: 'package.json', deps: [] }] }; branches = []; - platform.getPrBody = jest.fn((input) => input); + platform.massageMarkdown = jest.fn((input) => input); platform.createPr.mockResolvedValueOnce(partial<Pr>({})); setAdminConfig(); }); diff --git a/lib/workers/repository/onboarding/pr/index.ts b/lib/workers/repository/onboarding/pr/index.ts index d688979211644772474b469214b9dfd768cd715a..3b478a51d40c2e00829bec9214311995e711eb2c 100644 --- a/lib/workers/repository/onboarding/pr/index.ts +++ b/lib/workers/repository/onboarding/pr/index.ts @@ -102,7 +102,7 @@ If you need any further assistance then you can also [request help here](${confi } logger.trace('prBody:\n' + prBody); - prBody = platform.getPrBody(prBody); + prBody = platform.massageMarkdown(prBody); if (existingPr) { logger.debug('Found open onboarding PR');