From 18bdac9d35b63e1ab2a6eed3f061b7c921cb03f3 Mon Sep 17 00:00:00 2001 From: Adam Setch <adam.setch@outlook.com> Date: Thu, 23 Feb 2023 01:01:44 -0500 Subject: [PATCH] fix(platform/bitbucket): remove blockquote markdown from bitbucket issue description (#20588) --- .../bitbucket/__snapshots__/index.spec.ts.snap | 12 +++++++++++- lib/modules/platform/bitbucket/index.spec.ts | 6 ++++-- lib/modules/platform/bitbucket/index.ts | 7 ++++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/modules/platform/bitbucket/__snapshots__/index.spec.ts.snap b/lib/modules/platform/bitbucket/__snapshots__/index.spec.ts.snap index 02bcf79aa6..1818c5b636 100644 --- a/lib/modules/platform/bitbucket/__snapshots__/index.spec.ts.snap +++ b/lib/modules/platform/bitbucket/__snapshots__/index.spec.ts.snap @@ -140,7 +140,17 @@ exports[`modules/platform/bitbucket/index initRepo() works with username and pas } `; -exports[`modules/platform/bitbucket/index massageMarkdown() returns diff files 1`] = `"**foo**bartext"`; +exports[`modules/platform/bitbucket/index massageMarkdown() returns diff files 1`] = ` +"**foo** + + +**text** + + + + +" +`; exports[`modules/platform/bitbucket/index updatePr() rethrows exception when PR update error due to unknown reviewers error 1`] = `"Response code 400 (Bad Request)"`; diff --git a/lib/modules/platform/bitbucket/index.spec.ts b/lib/modules/platform/bitbucket/index.spec.ts index 32a85c0b51..6007fe9fdb 100644 --- a/lib/modules/platform/bitbucket/index.spec.ts +++ b/lib/modules/platform/bitbucket/index.spec.ts @@ -1059,8 +1059,10 @@ describe('modules/platform/bitbucket/index', () => { describe('massageMarkdown()', () => { it('returns diff files', () => { const prBody = - '<details><summary>foo</summary>bar</details>text<details>' + - '\n---\n\n - [ ] <!-- rebase-check --> rebase\n<!--renovate-config-hash:-->'; + '<details><summary>foo</summary>\n<blockquote>\n\n<details><summary>text</summary>' + + '\n---\n\n - [ ] <!-- rebase-check --> rebase\n<!--renovate-config-hash:-->' + + '\n\n</details>\n\n</blockquote>\n</details>'; + expect(bitbucket.massageMarkdown(prBody)).toMatchSnapshot(); }); }); diff --git a/lib/modules/platform/bitbucket/index.ts b/lib/modules/platform/bitbucket/index.ts index 818351c0d8..9755dc1806 100644 --- a/lib/modules/platform/bitbucket/index.ts +++ b/lib/modules/platform/bitbucket/index.ts @@ -486,7 +486,7 @@ export function massageMarkdown(input: string): string { 'by renaming this PR to start with "rebase!"' ) .replace(regEx(/<\/?summary>/g), '**') - .replace(regEx(/<\/?details>/g), '') + .replace(regEx(/<\/?(details|blockquote)>/g), '') .replace(regEx(`\n---\n\n.*?<!-- rebase-check -->.*?\n`), '') .replace(regEx(/\]\(\.\.\/pull\//g), '](../../pull-requests/') .replace(regEx(/<!--renovate-(?:debug|config-hash):.*?-->/g), ''); @@ -498,8 +498,6 @@ export async function ensureIssue({ body, }: EnsureIssueConfig): Promise<EnsureIssueResult | null> { logger.debug(`ensureIssue()`); - const description = massageMarkdown(sanitize(body)); - /* istanbul ignore if */ if (!config.has_issues) { logger.warn('Issues are disabled - cannot ensureIssue'); @@ -508,6 +506,8 @@ export async function ensureIssue({ } try { let issues = await findOpenIssues(title); + const description = massageMarkdown(sanitize(body)); + if (!issues.length && reuseTitle) { issues = await findOpenIssues(reuseTitle); } @@ -517,6 +517,7 @@ export async function ensureIssue({ await closeIssue(issue.id); } const [issue] = issues; + if ( issue.title !== title || String(issue.content?.raw).trim() !== description.trim() -- GitLab