From 35c1d9c844dcb2caac016a23bbde01bf9f3df176 Mon Sep 17 00:00:00 2001 From: Sergey Vedmak Date: Sun, 7 Nov 2021 21:03:39 +0300 Subject: [PATCH 1/9] fix(release notes): Show release notes from monorepo --- .../pr/__snapshots__/index.spec.ts.snap | 12 ++++---- lib/workers/pr/changelog/hbs-template.ts | 2 +- lib/workers/pr/changelog/release-notes.ts | 10 +++++-- lib/workers/pr/index.ts | 28 +++++++++++++++---- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/lib/workers/pr/__snapshots__/index.spec.ts.snap b/lib/workers/pr/__snapshots__/index.spec.ts.snap index 7ff26d4911972d..f208117cff2343 100644 --- a/lib/workers/pr/__snapshots__/index.spec.ts.snap +++ b/lib/workers/pr/__snapshots__/index.spec.ts.snap @@ -64,7 +64,7 @@ Array [ "gitLabIgnoreApprovals": false, "usePlatformAutomerge": false, }, - "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | pin | \`1.0.0\` -> \`1.1.0\` |\\n\\nšŸ“Œ **Important**: Renovate will wait until you have merged this Pin PR before creating any *upgrade* PRs for the affected packages. Add the preset \`:preserveSemverRanges\` to your config if you instead don't wish to pin dependencies.\\n\\n---\\n\\n### Release Notes\\n\\n
\\nrenovateapp/dummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" in timezone some timezone.\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", + "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | pin | \`1.0.0\` -> \`1.1.0\` |\\n\\nšŸ“Œ **Important**: Renovate will wait until you have merged this Pin PR before creating any *upgrade* PRs for the affected packages. Add the preset \`:preserveSemverRanges\` to your config if you instead don't wish to pin dependencies.\\n\\n---\\n\\n### Release Notes\\n\\n
\\ndummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" in timezone some timezone.\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", "sourceBranch": "renovate/dummy-1.x", "targetBranch": undefined, @@ -97,7 +97,7 @@ Array [ "gitLabIgnoreApprovals": false, "usePlatformAutomerge": false, }, - "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\nrenovateapp/dummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" (UTC).\\n\\nšŸš¦ **Automerge**: Enabled.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", + "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\ndummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" (UTC).\\n\\nšŸš¦ **Automerge**: Enabled.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", "sourceBranch": "renovate/dummy-1.x", "targetBranch": undefined, @@ -137,7 +137,7 @@ Array [ "gitLabIgnoreApprovals": false, "usePlatformAutomerge": false, }, - "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | lockFileMaintenance | \`1.0.0\` -> \`1.1.0\` |\\n| a | | | \`zzzzzz\` -> \`aaaaaaa\` |\\n| b | | pin | \`some_old_value\` -> \`some_new_value\` |\\n| c | | | \`\` -> \`\` |\\n| d | | lockFileMaintenance | \`\` -> \`\` |\\n\\nnote 1\\n\\nnote 2\\n\\n:warning: Release Notes retrieval for this PR were skipped because no github.com credentials were available.\\nIf you are self-hosted, please see [this instruction](https://github.com/renovatebot/renovate/blob/master/docs/usage/examples/self-hosting.md#githubcom-token-for-release-notes).\\n\\nšŸ”” If you wish to disable git hash updates, add \`\\":disableDigestUpdates\\"\` to the extends array in your config.\\n\\nšŸ”§ This Pull Request updates lock files to use the latest dependency versions.\\n\\n---\\n\\n### Release Notes\\n\\n
\\nrenovateapp/dummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n
\\nrenovateapp/dummy\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: At any time (no schedule defined).\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Never, or you tick the rebase/retry checkbox.\\n\\nšŸ‘» **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", + "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | lockFileMaintenance | \`1.0.0\` -> \`1.1.0\` |\\n| a | | | \`zzzzzz\` -> \`aaaaaaa\` |\\n| b | | pin | \`some_old_value\` -> \`some_new_value\` |\\n| c | | | \`\` -> \`\` |\\n| d | | lockFileMaintenance | \`\` -> \`\` |\\n\\nnote 1\\n\\nnote 2\\n\\n:warning: Release Notes retrieval for this PR were skipped because no github.com credentials were available.\\nIf you are self-hosted, please see [this instruction](https://github.com/renovatebot/renovate/blob/master/docs/usage/examples/self-hosting.md#githubcom-token-for-release-notes).\\n\\nšŸ”” If you wish to disable git hash updates, add \`\\":disableDigestUpdates\\"\` to the extends array in your config.\\n\\nšŸ”§ This Pull Request updates lock files to use the latest dependency versions.\\n\\n---\\n\\n### Release Notes\\n\\n
\\ndummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n
\\nb\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: At any time (no schedule defined).\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Never, or you tick the rebase/retry checkbox.\\n\\nšŸ‘» **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", "sourceBranch": "renovate/dummy-1.x", "targetBranch": undefined, @@ -157,7 +157,7 @@ Array [ "gitLabIgnoreApprovals": false, "usePlatformAutomerge": false, }, - "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\nsomeproject\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: At any time (no schedule defined).\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", + "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\ndummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: At any time (no schedule defined).\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", "sourceBranch": "renovate/dummy-1.x", "targetBranch": undefined, @@ -231,7 +231,7 @@ Array [ exports[`workers/pr/index ensurePr should return modified existing PR 1`] = ` Object { - "body": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\nrenovateapp/dummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" (UTC).\\n\\nšŸš¦ **Automerge**: Enabled.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", + "body": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\ndummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" (UTC).\\n\\nšŸš¦ **Automerge**: Enabled.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "displayNumber": "Existing PR", "title": "Update dependency dummy to v1.1.0", } @@ -239,7 +239,7 @@ Object { exports[`workers/pr/index ensurePr should return modified existing PR title 1`] = ` Object { - "body": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\nrenovateapp/dummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" (UTC).\\n\\nšŸš¦ **Automerge**: Enabled.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", + "body": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\ndummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" (UTC).\\n\\nšŸš¦ **Automerge**: Enabled.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "displayNumber": "Existing PR", "title": "wrong", } diff --git a/lib/workers/pr/changelog/hbs-template.ts b/lib/workers/pr/changelog/hbs-template.ts index 35521b9872be84..7a3d4ed6d9c029 100644 --- a/lib/workers/pr/changelog/hbs-template.ts +++ b/lib/workers/pr/changelog/hbs-template.ts @@ -5,7 +5,7 @@ export default `### Release Notes {{#if upgrade.hasReleaseNotes}}
-{{upgrade.repoName}} +{{upgrade.depName}} {{#each upgrade.releases as |release|}} diff --git a/lib/workers/pr/changelog/release-notes.ts b/lib/workers/pr/changelog/release-notes.ts index f365fde6e9a468..c8f96a3232fda9 100644 --- a/lib/workers/pr/changelog/release-notes.ts +++ b/lib/workers/pr/changelog/release-notes.ts @@ -207,7 +207,9 @@ export async function getReleaseNotesMdFileInner( export function getReleaseNotesMdFile( project: ChangeLogProject ): Promise { - const cacheKey = `getReleaseNotesMdFile-${project.repository}-${project.apiBaseUrl}`; + const cacheKey = `getReleaseNotesMdFile-${project.repository}${ + project.sourceDirectory ? `-${project.sourceDirectory}` : '' + }-${project.apiBaseUrl}`; const cachedResult = memCache.get>(cacheKey); // istanbul ignore if if (cachedResult !== undefined) { @@ -320,10 +322,12 @@ export async function addReleaseNotes( return input; } const output: ChangeLogResult = { ...input, versions: [] }; - const repository = input.project.repository; + const { repository, sourceDirectory } = input.project; const cacheNamespace = `changelog-${input.project.type}-notes`; function getCacheKey(version: string): string { - return `${repository}:${version}`; + return `${repository}:${ + sourceDirectory ? `${sourceDirectory}:` : '' + }${version}`; } for (const v of input.versions) { let releaseNotes: ChangeLogNotes; diff --git a/lib/workers/pr/index.ts b/lib/workers/pr/index.ts index 3825a54145a2d1..d8e695e4d237c2 100644 --- a/lib/workers/pr/index.ts +++ b/lib/workers/pr/index.ts @@ -16,7 +16,7 @@ import { regEx } from '../../util/regex'; import * as template from '../../util/template'; import { resolveBranchStatus } from '../branch/status-checks'; import { Limit, incLimitedValue, isLimitReached } from '../global/limits'; -import type { BranchConfig, PrBlockedBy } from '../types'; +import type { BranchConfig, BranchUpgradeConfig, PrBlockedBy } from '../types'; import { getPrBody } from './body'; import { ChangeLogError } from './changelog/types'; import { codeOwnersForPr } from './code-owners'; @@ -256,6 +256,14 @@ export async function ensurePr( const processedUpgrades: string[] = []; const commitRepos: string[] = []; + function getRepoNameWithSourceDirectory( + upgrade: BranchUpgradeConfig + ): string { + return `${upgrade.repoName}${ + upgrade.sourceDirectory ? `:${upgrade.sourceDirectory}` : '' + }`; + } + // Get changelog and then generate template strings for (const upgrade of upgrades) { const upgradeKey = `${upgrade.depType}-${upgrade.depName}-${ @@ -278,9 +286,9 @@ export async function ensurePr( if ( upgrade.hasReleaseNotes && upgrade.repoName && - !commitRepos.includes(upgrade.repoName) + !commitRepos.includes(getRepoNameWithSourceDirectory(upgrade)) ) { - commitRepos.push(upgrade.repoName); + commitRepos.push(getRepoNameWithSourceDirectory(upgrade)); if (logJSON.versions) { logJSON.versions.forEach((version) => { const release = { ...version }; @@ -305,17 +313,27 @@ export async function ensurePr( config.hasReleaseNotes = config.upgrades.some((upg) => upg.hasReleaseNotes); + function getRepoSourceUrlWithSourceDirectory( + upgrade: BranchUpgradeConfig + ): string { + return `${upgrade.sourceUrl}${ + upgrade.sourceDirectory ? `:${upgrade.sourceDirectory}` : '' + }`; + } + const releaseNoteRepos: string[] = []; for (const upgrade of config.upgrades) { if (upgrade.hasReleaseNotes) { - if (releaseNoteRepos.includes(upgrade.sourceUrl)) { + if ( + releaseNoteRepos.includes(getRepoSourceUrlWithSourceDirectory(upgrade)) + ) { logger.debug( { depName: upgrade.depName }, 'Removing duplicate release notes' ); upgrade.hasReleaseNotes = false; } else { - releaseNoteRepos.push(upgrade.sourceUrl); + releaseNoteRepos.push(getRepoSourceUrlWithSourceDirectory(upgrade)); } } } From 4c199493fe250c86394789b0950cd936e22116fb Mon Sep 17 00:00:00 2001 From: Sergey Vedmak Date: Thu, 11 Nov 2021 16:45:56 +0300 Subject: [PATCH 2/9] new logic to deduplicate release notes --- lib/datasource/types.ts | 2 ++ .../pr/__snapshots__/index.spec.ts.snap | 12 +++++----- lib/workers/pr/body/changelogs.ts | 20 ++++++++++++++++ .../__snapshots__/github.spec.ts.snap | 12 ++++++++++ .../__snapshots__/gitlab.spec.ts.snap | 4 ++++ .../__snapshots__/index.spec.ts.snap | 15 ++++++++++++ .../__snapshots__/release-notes.spec.ts.snap | 24 +++++++++++++++++++ lib/workers/pr/changelog/github/index.ts | 9 +++---- lib/workers/pr/changelog/gitlab/index.ts | 1 + lib/workers/pr/changelog/hbs-template.ts | 2 +- lib/workers/pr/changelog/release-notes.ts | 10 +++++--- lib/workers/pr/changelog/types.ts | 2 ++ lib/workers/pr/index.ts | 21 ++++++---------- lib/workers/types.ts | 1 + 14 files changed, 107 insertions(+), 28 deletions(-) diff --git a/lib/datasource/types.ts b/lib/datasource/types.ts index 1d271a8a9ad17d..aac3b244502b15 100644 --- a/lib/datasource/types.ts +++ b/lib/datasource/types.ts @@ -1,3 +1,4 @@ +import type { ChangeLogNotes } from '../workers/pr/changelog/types'; export interface Config { datasource?: string; depName?: string; @@ -46,6 +47,7 @@ export interface Release { registryUrl?: string; sourceUrl?: string; sourceDirectory?: string; + releaseNotes?: ChangeLogNotes; } export interface ReleaseResult { diff --git a/lib/workers/pr/__snapshots__/index.spec.ts.snap b/lib/workers/pr/__snapshots__/index.spec.ts.snap index f208117cff2343..3a4d5a59433d7b 100644 --- a/lib/workers/pr/__snapshots__/index.spec.ts.snap +++ b/lib/workers/pr/__snapshots__/index.spec.ts.snap @@ -64,7 +64,7 @@ Array [ "gitLabIgnoreApprovals": false, "usePlatformAutomerge": false, }, - "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | pin | \`1.0.0\` -> \`1.1.0\` |\\n\\nšŸ“Œ **Important**: Renovate will wait until you have merged this Pin PR before creating any *upgrade* PRs for the affected packages. Add the preset \`:preserveSemverRanges\` to your config if you instead don't wish to pin dependencies.\\n\\n---\\n\\n### Release Notes\\n\\n
\\ndummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" in timezone some timezone.\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", + "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | pin | \`1.0.0\` -> \`1.1.0\` |\\n\\nšŸ“Œ **Important**: Renovate will wait until you have merged this Pin PR before creating any *upgrade* PRs for the affected packages. Add the preset \`:preserveSemverRanges\` to your config if you instead don't wish to pin dependencies.\\n\\n---\\n\\n### Release Notes\\n\\n
\\nrenovateapp/dummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" in timezone some timezone.\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", "sourceBranch": "renovate/dummy-1.x", "targetBranch": undefined, @@ -97,7 +97,7 @@ Array [ "gitLabIgnoreApprovals": false, "usePlatformAutomerge": false, }, - "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\ndummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" (UTC).\\n\\nšŸš¦ **Automerge**: Enabled.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", + "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\nrenovateapp/dummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" (UTC).\\n\\nšŸš¦ **Automerge**: Enabled.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", "sourceBranch": "renovate/dummy-1.x", "targetBranch": undefined, @@ -137,7 +137,7 @@ Array [ "gitLabIgnoreApprovals": false, "usePlatformAutomerge": false, }, - "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | lockFileMaintenance | \`1.0.0\` -> \`1.1.0\` |\\n| a | | | \`zzzzzz\` -> \`aaaaaaa\` |\\n| b | | pin | \`some_old_value\` -> \`some_new_value\` |\\n| c | | | \`\` -> \`\` |\\n| d | | lockFileMaintenance | \`\` -> \`\` |\\n\\nnote 1\\n\\nnote 2\\n\\n:warning: Release Notes retrieval for this PR were skipped because no github.com credentials were available.\\nIf you are self-hosted, please see [this instruction](https://github.com/renovatebot/renovate/blob/master/docs/usage/examples/self-hosting.md#githubcom-token-for-release-notes).\\n\\nšŸ”” If you wish to disable git hash updates, add \`\\":disableDigestUpdates\\"\` to the extends array in your config.\\n\\nšŸ”§ This Pull Request updates lock files to use the latest dependency versions.\\n\\n---\\n\\n### Release Notes\\n\\n
\\ndummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n
\\nb\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: At any time (no schedule defined).\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Never, or you tick the rebase/retry checkbox.\\n\\nšŸ‘» **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", + "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | lockFileMaintenance | \`1.0.0\` -> \`1.1.0\` |\\n| a | | | \`zzzzzz\` -> \`aaaaaaa\` |\\n| b | | pin | \`some_old_value\` -> \`some_new_value\` |\\n| c | | | \`\` -> \`\` |\\n| d | | lockFileMaintenance | \`\` -> \`\` |\\n\\nnote 1\\n\\nnote 2\\n\\n:warning: Release Notes retrieval for this PR were skipped because no github.com credentials were available.\\nIf you are self-hosted, please see [this instruction](https://github.com/renovatebot/renovate/blob/master/docs/usage/examples/self-hosting.md#githubcom-token-for-release-notes).\\n\\nšŸ”” If you wish to disable git hash updates, add \`\\":disableDigestUpdates\\"\` to the extends array in your config.\\n\\nšŸ”§ This Pull Request updates lock files to use the latest dependency versions.\\n\\n---\\n\\n### Release Notes\\n\\n
\\nrenovateapp/dummy (dummy)\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n
\\nrenovateapp/dummy (b)\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n
\\nrenovateapp/dummy (c)\\n\\n
\\n\\n
\\nrenovateapp/dummy (d)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: At any time (no schedule defined).\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Never, or you tick the rebase/retry checkbox.\\n\\nšŸ‘» **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", "sourceBranch": "renovate/dummy-1.x", "targetBranch": undefined, @@ -157,7 +157,7 @@ Array [ "gitLabIgnoreApprovals": false, "usePlatformAutomerge": false, }, - "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\ndummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: At any time (no schedule defined).\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", + "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\nsomeproject\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: At any time (no schedule defined).\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", "sourceBranch": "renovate/dummy-1.x", "targetBranch": undefined, @@ -231,7 +231,7 @@ Array [ exports[`workers/pr/index ensurePr should return modified existing PR 1`] = ` Object { - "body": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\ndummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" (UTC).\\n\\nšŸš¦ **Automerge**: Enabled.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", + "body": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\nrenovateapp/dummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" (UTC).\\n\\nšŸš¦ **Automerge**: Enabled.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "displayNumber": "Existing PR", "title": "Update dependency dummy to v1.1.0", } @@ -239,7 +239,7 @@ Object { exports[`workers/pr/index ensurePr should return modified existing PR title 1`] = ` Object { - "body": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\ndummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" (UTC).\\n\\nšŸš¦ **Automerge**: Enabled.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", + "body": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\nrenovateapp/dummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" (UTC).\\n\\nšŸš¦ **Automerge**: Enabled.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "displayNumber": "Existing PR", "title": "wrong", } diff --git a/lib/workers/pr/body/changelogs.ts b/lib/workers/pr/body/changelogs.ts index 73aa37c51d5f77..ad7b3660e5ebe8 100644 --- a/lib/workers/pr/body/changelogs.ts +++ b/lib/workers/pr/body/changelogs.ts @@ -11,6 +11,26 @@ export function getChangelogs(config: BranchConfig): string { if (!config.hasReleaseNotes) { return releaseNotes; } + + const countReleaseNodesByRepoName: Record = {}; + + for (const upgrade of config.upgrades) { + if (upgrade.hasReleaseNotes) { + countReleaseNodesByRepoName[upgrade.repoName] = + (countReleaseNodesByRepoName[upgrade.repoName] || 0) + 1; + } + } + + for (const upgrade of config.upgrades) { + if (upgrade.hasReleaseNotes) { + upgrade.releaseNotesSummaryTitle = `${upgrade.repoName}${ + countReleaseNodesByRepoName[upgrade.repoName] > 1 + ? ` (${upgrade.depName})` + : '' + }`; + } + } + releaseNotes += '\n\n---\n\n' + template.compile(releaseNotesHbs, config, false) + '\n\n'; releaseNotes = releaseNotes.replace(regEx(/### \[`vv/g), '### [`v'); diff --git a/lib/workers/pr/changelog/__snapshots__/github.spec.ts.snap b/lib/workers/pr/changelog/__snapshots__/github.spec.ts.snap index a97678ef16b0b3..dfc462b844d482 100644 --- a/lib/workers/pr/changelog/__snapshots__/github.spec.ts.snap +++ b/lib/workers/pr/changelog/__snapshots__/github.spec.ts.snap @@ -34,6 +34,7 @@ Object { }, "date": "2017-10-24T03:20:46.238Z", "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_2.2.2...npm_2.3.0", }, "version": "2.3.0", @@ -45,6 +46,7 @@ Object { }, "date": undefined, "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_1.0.0...npm_2.2.2", }, "version": "2.2.2", @@ -87,6 +89,7 @@ Object { }, "date": "2017-10-24T03:20:46.238Z", "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github-enterprise.example.com/chalk/chalk/compare/npm_2.2.2...npm_2.3.0", }, "version": "2.3.0", @@ -98,6 +101,7 @@ Object { }, "date": undefined, "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github-enterprise.example.com/chalk/chalk/compare/npm_1.0.0...npm_2.2.2", }, "version": "2.2.2", @@ -140,6 +144,7 @@ Object { }, "date": "2017-10-24T03:20:46.238Z", "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_2.2.2...npm_2.3.0", }, "version": "2.3.0", @@ -151,6 +156,7 @@ Object { }, "date": undefined, "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_1.0.0...npm_2.2.2", }, "version": "2.2.2", @@ -193,6 +199,7 @@ Object { }, "date": "2017-10-24T03:20:46.238Z", "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_2.2.2...npm_2.3.0", }, "version": "2.3.0", @@ -204,6 +211,7 @@ Object { }, "date": undefined, "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_1.0.0...npm_2.2.2", }, "version": "2.2.2", @@ -246,6 +254,7 @@ Object { }, "date": "2017-10-24T03:20:46.238Z", "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_2.2.2...npm_2.3.0", }, "version": "2.3.0", @@ -257,6 +266,7 @@ Object { }, "date": undefined, "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_1.0.0...npm_2.2.2", }, "version": "2.2.2", @@ -299,6 +309,7 @@ Object { }, "date": "2017-10-24T03:20:46.238Z", "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_2.2.2...npm_2.3.0", }, "version": "2.3.0", @@ -310,6 +321,7 @@ Object { }, "date": undefined, "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_1.0.0...npm_2.2.2", }, "version": "2.2.2", diff --git a/lib/workers/pr/changelog/__snapshots__/gitlab.spec.ts.snap b/lib/workers/pr/changelog/__snapshots__/gitlab.spec.ts.snap index d02b4cdfbaf35f..ae886d87da5b3e 100644 --- a/lib/workers/pr/changelog/__snapshots__/gitlab.spec.ts.snap +++ b/lib/workers/pr/changelog/__snapshots__/gitlab.spec.ts.snap @@ -259,6 +259,7 @@ Object { }, "date": undefined, "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://gitlab.com/meno/dropzone/compare/v5.6.0...v5.6.1", }, "version": "5.6.1", @@ -270,6 +271,7 @@ Object { }, "date": "2020-02-13T15:37:00.000Z", "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://gitlab.com/meno/dropzone/compare/v5.5.0...v5.6.0", }, "version": "5.6.0", @@ -281,6 +283,7 @@ Object { }, "date": undefined, "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://gitlab.com/meno/dropzone/compare/v5.4.0...v5.5.0", }, "version": "5.5.0", @@ -292,6 +295,7 @@ Object { }, "date": "2018-08-24T14:23:00.000Z", "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://gitlab.com/meno/dropzone/compare/v5.2.0...v5.4.0", }, "version": "5.4.0", diff --git a/lib/workers/pr/changelog/__snapshots__/index.spec.ts.snap b/lib/workers/pr/changelog/__snapshots__/index.spec.ts.snap index f57ff11e1bfdda..688c33142244d7 100644 --- a/lib/workers/pr/changelog/__snapshots__/index.spec.ts.snap +++ b/lib/workers/pr/changelog/__snapshots__/index.spec.ts.snap @@ -34,6 +34,7 @@ Object { }, "date": "2017-10-24T03:20:46.238Z", "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_2.2.2...npm_2.3.0", }, "version": "2.3.0", @@ -45,6 +46,7 @@ Object { }, "date": undefined, "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_1.0.0...npm_2.2.2", }, "version": "2.2.2", @@ -191,6 +193,7 @@ Object { }, "date": "2017-10-24T03:20:46.238Z", "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github-enterprise.example.com/chalk/chalk/compare/npm_2.2.2...npm_2.3.0", }, "version": "2.3.0", @@ -202,6 +205,7 @@ Object { }, "date": undefined, "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github-enterprise.example.com/chalk/chalk/compare/npm_1.0.0...npm_2.2.2", }, "version": "2.2.2", @@ -392,6 +396,7 @@ Object { }, "date": "2017-10-24T03:20:46.238Z", "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_2.2.2...npm_2.3.0", }, "version": "2.3.0", @@ -403,6 +408,7 @@ Object { }, "date": undefined, "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_1.0.0...npm_2.2.2", }, "version": "2.2.2", @@ -593,6 +599,7 @@ Object { }, "date": "2017-10-24T03:20:46.238Z", "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github-enterprise.example.com/chalk/chalk/compare/npm_2.2.2...npm_2.3.0", }, "version": "2.3.0", @@ -604,6 +611,7 @@ Object { }, "date": undefined, "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github-enterprise.example.com/chalk/chalk/compare/npm_1.0.0...npm_2.2.2", }, "version": "2.2.2", @@ -794,6 +802,7 @@ Object { }, "date": "2017-10-24T03:20:46.238Z", "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_2.2.2...npm_2.3.0", }, "version": "2.3.0", @@ -805,6 +814,7 @@ Object { }, "date": undefined, "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_1.0.0...npm_2.2.2", }, "version": "2.2.2", @@ -840,6 +850,7 @@ Object { }, "date": "2017-12-24T03:20:46.238Z", "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/v2.3.0...v2.4.2", }, "version": "2.4.2", @@ -851,6 +862,7 @@ Object { }, "date": "2017-10-24T03:20:46.238Z", "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/2.2.2...v2.3.0", }, "version": "2.3.0", @@ -862,6 +874,7 @@ Object { }, "date": undefined, "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/1.0.0...2.2.2", }, "version": "2.2.2", @@ -1052,6 +1065,7 @@ Object { }, "date": "2017-10-24T03:20:46.238Z", "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_2.2.2...npm_2.3.0", }, "version": "2.3.0", @@ -1063,6 +1077,7 @@ Object { }, "date": undefined, "releaseNotes": Object { + "notesSourceUrl": "", "url": "https://github.com/chalk/chalk/compare/npm_1.0.0...npm_2.2.2", }, "version": "2.2.2", diff --git a/lib/workers/pr/changelog/__snapshots__/release-notes.spec.ts.snap b/lib/workers/pr/changelog/__snapshots__/release-notes.spec.ts.snap index 4386f098d4e6cd..bd95f1cb5cd9c4 100644 --- a/lib/workers/pr/changelog/__snapshots__/release-notes.spec.ts.snap +++ b/lib/workers/pr/changelog/__snapshots__/release-notes.spec.ts.snap @@ -46,6 +46,7 @@ Array [ "body": undefined, "id": undefined, "name": undefined, + "notesSourceUrl": "https://api.github.com/repos/some/yet-other-repository/releases", "tag": "v1.0.0", "url": undefined, }, @@ -53,6 +54,7 @@ Array [ "body": "some body #123, [#124](https://github.com/some/yet-other-repository/issues/124)", "id": undefined, "name": undefined, + "notesSourceUrl": "https://api.github.com/repos/some/yet-other-repository/releases", "tag": "v1.0.1", "url": undefined, }, @@ -79,12 +81,14 @@ Array [ Object { "body": undefined, "name": undefined, + "notesSourceUrl": "https://gitlab.com/api/v4/projects/some%2fyet-other-repository/releases", "tag": "v1.0.0", "url": "https://gitlab.com/api/v4/projects/some%2fyet-other-repository/releases/v1.0.0", }, Object { "body": undefined, "name": undefined, + "notesSourceUrl": "https://gitlab.com/api/v4/projects/some%2fyet-other-repository/releases", "tag": "v1.0.1", "url": "https://gitlab.com/api/v4/projects/some%2fyet-other-repository/releases/v1.0.1", }, @@ -111,12 +115,14 @@ Array [ Object { "body": undefined, "name": undefined, + "notesSourceUrl": "https://my.custom.domain/api/v4/projects/some%2fyet-other-repository/releases", "tag": "v1.0.0", "url": "https://my.custom.domain/api/v4/projects/some%2fyet-other-repository/releases/v1.0.0", }, Object { "body": undefined, "name": undefined, + "notesSourceUrl": "https://my.custom.domain/api/v4/projects/some%2fyet-other-repository/releases", "tag": "v1.0.1", "url": "https://my.custom.domain/api/v4/projects/some%2fyet-other-repository/releases/v1.0.1", }, @@ -145,6 +151,7 @@ Object { ", "id": undefined, "name": undefined, + "notesSourceUrl": "https://api.github.com/repos/some/other-repository/releases", "tag": "1.0.1", "url": "https://github.com/some/other-repository/releases/1.0.1", } @@ -171,6 +178,7 @@ Object { ", "id": undefined, "name": undefined, + "notesSourceUrl": "https://api.github.com/repos/some/other-repository/releases", "tag": "other@1.0.1", "url": "https://github.com/some/other-repository/releases/other@1.0.1", } @@ -197,6 +205,7 @@ Object { ", "id": undefined, "name": undefined, + "notesSourceUrl": "https://api.github.com/repos/some/other-repository/releases", "tag": "other_v1.0.1", "url": "https://github.com/some/other-repository/releases/other_v1.0.1", } @@ -223,6 +232,7 @@ Object { ", "id": undefined, "name": undefined, + "notesSourceUrl": "https://api.github.com/repos/some/other-repository/releases", "tag": "other-1.0.1", "url": "https://github.com/some/other-repository/releases/other-1.0.1", } @@ -249,6 +259,7 @@ Object { ", "id": undefined, "name": undefined, + "notesSourceUrl": "https://api.github.com/repos/some/other-repository/releases", "tag": "v1.0.1", "url": "https://github.com/some/other-repository/releases/v1.0.1", } @@ -273,6 +284,7 @@ exports[`workers/pr/changelog/release-notes getReleaseNotes() gets release notes Object { "body": "some body #123, [#124](https://gitlab.com/some/yet-other-repository/issues/124)", "name": undefined, + "notesSourceUrl": "https://api.gitlab.com/projects/some%2fother-repository/releases", "tag": "1.0.1", "url": "https://gitlab.com/some/other-repository/tags/1.0.1", } @@ -297,6 +309,7 @@ exports[`workers/pr/changelog/release-notes getReleaseNotes() gets release notes Object { "body": "some body #123, [#124](https://gitlab.com/some/yet-other-repository/issues/124)", "name": undefined, + "notesSourceUrl": "https://api.gitlab.com/projects/some%2fother-repository/releases", "tag": "other-1.0.1", "url": "https://gitlab.com/some/other-repository/tags/other-1.0.1", } @@ -321,6 +334,7 @@ exports[`workers/pr/changelog/release-notes getReleaseNotes() gets release notes Object { "body": "some body #123, [#124](https://gitlab.com/some/yet-other-repository/issues/124)", "name": undefined, + "notesSourceUrl": "https://api.gitlab.com/projects/some%2fother-repository/releases", "tag": "v1.0.1", "url": "https://gitlab.com/some/other-repository/tags/v1.0.1", } @@ -390,6 +404,7 @@ See merge request itentialopensource/adapter-utils!177 *** ", + "notesSourceUrl": "https://gitlab.com/itentialopensource/adapter-utils/blob/master/packages/foo/CHANGELOG.md", "url": "https://gitlab.com/itentialopensource/adapter-utils/blob/master/packages/foo/CHANGELOG.md#4330-05-15-2020", } `; @@ -428,6 +443,7 @@ See merge request itentialopensource/adapter-utils!177 *** ", + "notesSourceUrl": "https://gitlab.com/itentialopensource/adapter-utils/blob/master/CHANGELOG.md", "url": "https://gitlab.com/itentialopensource/adapter-utils/blob/master/CHANGELOG.md#4330-05-15-2020", } `; @@ -493,6 +509,7 @@ Object { - **translations:** fix pluralization in error messages. ([#1557](https://www.github.com/yargs/yargs/issues/1557)) ([94fa38c](https://www.github.com/yargs/yargs/commit/94fa38cbab8d86943e87bf41d368ed56dffa6835)) - **yargs:** correct support of bundled electron apps ([#1554](https://www.github.com/yargs/yargs/issues/1554)) ([a0b61ac](https://www.github.com/yargs/yargs/commit/a0b61ac21e2b554aa73dbf1a66d4a7af94047c2f)) ", + "notesSourceUrl": "https://github.com/yargs/yargs/blob/master/CHANGELOG.md", "url": "https://github.com/yargs/yargs/blob/master/CHANGELOG.md#1520-httpswwwgithubcomyargsyargscomparev1510v1520-2020-03-01", } `; @@ -543,6 +560,7 @@ Object { - address ambiguity between nargs of 1 and requiresArg ([#1572](https://www.github.com/yargs/yargs/issues/1572)) ([a5edc32](https://www.github.com/yargs/yargs/commit/a5edc328ecb3f90d1ba09cfe70a0040f68adf50a)) ", + "notesSourceUrl": "https://github.com/yargs/yargs/blob/master/CHANGELOG.md", "url": "https://github.com/yargs/yargs/blob/master/CHANGELOG.md#1530-httpswwwgithubcomyargsyargscomparev1520v1530-2020-03-08", } `; @@ -647,6 +665,7 @@ Object { "body": "- Fix \`condenseFlow\` output (quote keys for sure, instead of spaces), [#371](https://github.com/nodeca/js-yaml/issues/371), [#370](https://github.com/nodeca/js-yaml/issues/370). - Dump astrals as codepoints instead of surrogate pair, [#368](https://github.com/nodeca/js-yaml/issues/368). ", + "notesSourceUrl": "https://github.com/nodeca/js-yaml/blob/master/packages/foo/CHANGELOG.md", "url": "https://github.com/nodeca/js-yaml/blob/master/packages/foo/CHANGELOG.md#3100--2017-09-10", } `; @@ -712,6 +731,7 @@ Object { [#15085](https://github.com/angular/angular.js/issues/15085), [#15105](https://github.com/angular/angular.js/issues/15105)) ", + "notesSourceUrl": "https://github.com/angular/angular.js/blob/master/CHANGELOG.md", "url": "https://github.com/angular/angular.js/blob/master/CHANGELOG.md#169-fiery-basilisk-2018-02-02", } `; @@ -787,6 +807,7 @@ Object { - Update Polish translation, - Thanks to [@biesiad](https://gitlab.com/biesiad) for the contribution ", + "notesSourceUrl": "https://gitlab.com/gitlab-org/gitter/webapp/blob/master/CHANGELOG.md", "url": "https://gitlab.com/gitlab-org/gitter/webapp/blob/master/CHANGELOG.md#20260---2020-05-18", } `; @@ -1014,6 +1035,7 @@ Object { - \`[docs]\` Update \`expect.anything()\` sample code ([#5007](https://github.com/facebook/jest/pull/5007)) ", + "notesSourceUrl": "https://github.com/facebook/jest/blob/master/CHANGELOG.md", "url": "https://github.com/facebook/jest/blob/master/CHANGELOG.md#jest-2200", } `; @@ -1058,6 +1080,7 @@ Object { "body": "- Fix \`condenseFlow\` output (quote keys for sure, instead of spaces), [#371](https://github.com/nodeca/js-yaml/issues/371), [#370](https://github.com/nodeca/js-yaml/issues/370). - Dump astrals as codepoints instead of surrogate pair, [#368](https://github.com/nodeca/js-yaml/issues/368). ", + "notesSourceUrl": "https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md", "url": "https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md#3100--2017-09-10", } `; @@ -1100,6 +1123,7 @@ Object { - Update Polish translation, - Thanks to [@biesiad](https://gitlab.com/biesiad) for the contribution ", + "notesSourceUrl": "https://my.custom.domain/gitlab-org/gitter/webapp/blob/master/CHANGELOG.md", "url": "https://my.custom.domain/gitlab-org/gitter/webapp/blob/master/CHANGELOG.md#20260---2020-05-18", } `; diff --git a/lib/workers/pr/changelog/github/index.ts b/lib/workers/pr/changelog/github/index.ts index 354e7da27d6308..d73cc320940701 100644 --- a/lib/workers/pr/changelog/github/index.ts +++ b/lib/workers/pr/changelog/github/index.ts @@ -109,12 +109,13 @@ export async function getReleaseList( repository: string ): Promise { logger.trace('github.getReleaseList()'); - const url = `${ensureTrailingSlash( - apiBaseUrl - )}repos/${repository}/releases?per_page=100`; - const res = await http.getJson(url, { paginate: true }); + const url = `${ensureTrailingSlash(apiBaseUrl)}repos/${repository}/releases`; + const res = await http.getJson(`${url}?per_page=100`, { + paginate: true, + }); return res.body.map((release) => ({ url: release.html_url, + notesSourceUrl: url, id: release.id, tag: release.tag_name, name: release.name, diff --git a/lib/workers/pr/changelog/gitlab/index.ts b/lib/workers/pr/changelog/gitlab/index.ts index 3364cffb9e1a44..11217cb77e71ed 100644 --- a/lib/workers/pr/changelog/gitlab/index.ts +++ b/lib/workers/pr/changelog/gitlab/index.ts @@ -109,6 +109,7 @@ export async function getReleaseList( }); return res.body.map((release) => ({ url: `${apiUrl}/${release.tag_name}`, + notesSourceUrl: apiUrl, name: release.name, body: release.description, tag: release.tag_name, diff --git a/lib/workers/pr/changelog/hbs-template.ts b/lib/workers/pr/changelog/hbs-template.ts index 7a3d4ed6d9c029..5de10f0658edbe 100644 --- a/lib/workers/pr/changelog/hbs-template.ts +++ b/lib/workers/pr/changelog/hbs-template.ts @@ -5,7 +5,7 @@ export default `### Release Notes {{#if upgrade.hasReleaseNotes}}
-{{upgrade.depName}} +{{upgrade.releaseNotesSummaryTitle}} {{#each upgrade.releases as |release|}} diff --git a/lib/workers/pr/changelog/release-notes.ts b/lib/workers/pr/changelog/release-notes.ts index c8f96a3232fda9..5a7ab6beba95ad 100644 --- a/lib/workers/pr/changelog/release-notes.ts +++ b/lib/workers/pr/changelog/release-notes.ts @@ -260,8 +260,11 @@ export async function getReleaseNotesMd( if (word.includes(version) && !isUrl(word)) { logger.trace({ body }, 'Found release notes for v' + version); // TODO: fix url - let url = `${baseUrl}${repository}/blob/master/${changelogFile}#`; - url += title.join('-').replace(regEx(/[^A-Za-z0-9-]/g), ''); // TODO #12071 + const notesSourceUrl = `${baseUrl}${repository}/blob/master/${changelogFile}`; + const url = + notesSourceUrl + + '#' + + title.join('-').replace(regEx(/[^A-Za-z0-9-]/g), ''); // TODO #12071 body = massageBody(body, baseUrl); if (body?.length) { try { @@ -275,6 +278,7 @@ export async function getReleaseNotesMd( return { body, url, + notesSourceUrl, }; } } @@ -342,7 +346,7 @@ export async function addReleaseNotes( } // Small hack to force display of release notes when there is a compare url if (!releaseNotes && v.compare.url) { - releaseNotes = { url: v.compare.url }; + releaseNotes = { url: v.compare.url, notesSourceUrl: '' }; } const cacheMinutes = releaseNotesCacheMinutes(v.date); await packageCache.set( diff --git a/lib/workers/pr/changelog/types.ts b/lib/workers/pr/changelog/types.ts index 48217fc59eab65..8569d7015ca0cd 100644 --- a/lib/workers/pr/changelog/types.ts +++ b/lib/workers/pr/changelog/types.ts @@ -3,6 +3,8 @@ export interface ChangeLogNotes { id?: number; name?: string; tag?: string; + // url to changelog.md file or github/gitlab release api + notesSourceUrl: string; url: string; } diff --git a/lib/workers/pr/index.ts b/lib/workers/pr/index.ts index d8e695e4d237c2..e04a25b8886e91 100644 --- a/lib/workers/pr/index.ts +++ b/lib/workers/pr/index.ts @@ -313,27 +313,20 @@ export async function ensurePr( config.hasReleaseNotes = config.upgrades.some((upg) => upg.hasReleaseNotes); - function getRepoSourceUrlWithSourceDirectory( - upgrade: BranchUpgradeConfig - ): string { - return `${upgrade.sourceUrl}${ - upgrade.sourceDirectory ? `:${upgrade.sourceDirectory}` : '' - }`; - } - - const releaseNoteRepos: string[] = []; + const releaseNotesSources: string[] = []; for (const upgrade of config.upgrades) { - if (upgrade.hasReleaseNotes) { - if ( - releaseNoteRepos.includes(getRepoSourceUrlWithSourceDirectory(upgrade)) - ) { + const notesSourceUrl = + upgrade.releases?.[0]?.releaseNotes?.notesSourceUrl || upgrade.sourceUrl; + + if (upgrade.hasReleaseNotes && notesSourceUrl.length > 0) { + if (releaseNotesSources.includes(notesSourceUrl)) { logger.debug( { depName: upgrade.depName }, 'Removing duplicate release notes' ); upgrade.hasReleaseNotes = false; } else { - releaseNoteRepos.push(getRepoSourceUrlWithSourceDirectory(upgrade)); + releaseNotesSources.push(notesSourceUrl); } } } diff --git a/lib/workers/types.ts b/lib/workers/types.ts index 401464f9664541..00dbf7fd7ed74a 100644 --- a/lib/workers/types.ts +++ b/lib/workers/types.ts @@ -61,6 +61,7 @@ export interface BranchUpgradeConfig logJSON?: ChangeLogResult; + hasReleaseNotes?: boolean; homepage?: string; changelogUrl?: string; dependencyUrl?: string; From dbd3458233c276f8d50b8e209f0a5706c4f3154c Mon Sep 17 00:00:00 2001 From: Sergey Vedmak Date: Thu, 11 Nov 2021 17:01:40 +0300 Subject: [PATCH 3/9] fix test --- lib/workers/pr/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/workers/pr/index.ts b/lib/workers/pr/index.ts index be8389fe1c4642..2267f260c8091f 100644 --- a/lib/workers/pr/index.ts +++ b/lib/workers/pr/index.ts @@ -318,7 +318,7 @@ export async function ensurePr( const notesSourceUrl = upgrade.releases?.[0]?.releaseNotes?.notesSourceUrl || upgrade.sourceUrl; - if (upgrade.hasReleaseNotes && notesSourceUrl.length > 0) { + if (upgrade.hasReleaseNotes && notesSourceUrl) { if (releaseNotesSources.includes(notesSourceUrl)) { logger.debug( { depName: upgrade.depName }, From d6bb85b601c05fc09153e2f78f1a876ccf4d61f4 Mon Sep 17 00:00:00 2001 From: Sergey Vedmak Date: Thu, 11 Nov 2021 18:13:44 +0300 Subject: [PATCH 4/9] fix test coverage --- lib/workers/pr/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/workers/pr/index.ts b/lib/workers/pr/index.ts index 2267f260c8091f..97c59088340efc 100644 --- a/lib/workers/pr/index.ts +++ b/lib/workers/pr/index.ts @@ -318,6 +318,7 @@ export async function ensurePr( const notesSourceUrl = upgrade.releases?.[0]?.releaseNotes?.notesSourceUrl || upgrade.sourceUrl; + // istanbul ignore if if (upgrade.hasReleaseNotes && notesSourceUrl) { if (releaseNotesSources.includes(notesSourceUrl)) { logger.debug( From eb0de0ab6df9d4120ef070bca90406a147bad5e5 Mon Sep 17 00:00:00 2001 From: Sergey Vedmak Date: Mon, 15 Nov 2021 17:48:29 +0300 Subject: [PATCH 5/9] Update lib/workers/pr/changelog/release-notes.ts Co-authored-by: Rhys Arkins --- lib/workers/pr/changelog/release-notes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/workers/pr/changelog/release-notes.ts b/lib/workers/pr/changelog/release-notes.ts index 5a7ab6beba95ad..830e715c469267 100644 --- a/lib/workers/pr/changelog/release-notes.ts +++ b/lib/workers/pr/changelog/release-notes.ts @@ -207,7 +207,7 @@ export async function getReleaseNotesMdFileInner( export function getReleaseNotesMdFile( project: ChangeLogProject ): Promise { - const cacheKey = `getReleaseNotesMdFile-${project.repository}${ + const cacheKey = `getReleaseNotesMdFile@v2-${project.repository}${ project.sourceDirectory ? `-${project.sourceDirectory}` : '' }-${project.apiBaseUrl}`; const cachedResult = memCache.get>(cacheKey); From be222528971dab253f674588ae507b4594b6c3c8 Mon Sep 17 00:00:00 2001 From: Sergey Vedmak Date: Mon, 15 Nov 2021 17:52:47 +0300 Subject: [PATCH 6/9] bump cache key --- lib/workers/pr/changelog/release-notes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/workers/pr/changelog/release-notes.ts b/lib/workers/pr/changelog/release-notes.ts index 830e715c469267..3f84a9cade2810 100644 --- a/lib/workers/pr/changelog/release-notes.ts +++ b/lib/workers/pr/changelog/release-notes.ts @@ -327,7 +327,7 @@ export async function addReleaseNotes( } const output: ChangeLogResult = { ...input, versions: [] }; const { repository, sourceDirectory } = input.project; - const cacheNamespace = `changelog-${input.project.type}-notes`; + const cacheNamespace = `changelog-${input.project.type}-notes@v2`; function getCacheKey(version: string): string { return `${repository}:${ sourceDirectory ? `${sourceDirectory}:` : '' From 1390a939b68c357a2f4a10bf897eb0325fd41ecf Mon Sep 17 00:00:00 2001 From: Sergey Vedmak Date: Mon, 29 Nov 2021 14:40:57 +0300 Subject: [PATCH 7/9] fix types --- lib/datasource/types.ts | 2 -- lib/workers/types.ts | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/datasource/types.ts b/lib/datasource/types.ts index d1b8a81907c321..c03502dde6a2c5 100644 --- a/lib/datasource/types.ts +++ b/lib/datasource/types.ts @@ -1,4 +1,3 @@ -import type { ChangeLogNotes } from '../workers/pr/changelog/types'; export interface Config { datasource?: string; depName?: string; @@ -49,7 +48,6 @@ export interface Release { registryUrl?: string; sourceUrl?: string; sourceDirectory?: string; - releaseNotes?: ChangeLogNotes; } export interface ReleaseResult { diff --git a/lib/workers/types.ts b/lib/workers/types.ts index 25bed6604f1dea..2d5cd94f65e814 100644 --- a/lib/workers/types.ts +++ b/lib/workers/types.ts @@ -16,7 +16,9 @@ import type { import type { PlatformPrOptions } from '../platform/types'; import type { File } from '../util/git/types'; import type { MergeConfidence } from '../util/merge-confidence'; -import type { ChangeLogResult } from './pr/changelog/types'; +import type { ChangeLogNotes, ChangeLogResult } from './pr/changelog/types'; + +export type BranchUpgrade = Release & { releaseNotes?: ChangeLogNotes }; export interface BranchUpgradeConfig extends Merge, @@ -50,7 +52,7 @@ export interface BranchUpgradeConfig prBodyTemplate?: string; prPriority?: number; prTitle?: string; - releases?: Release[]; + releases?: BranchUpgrade[]; releaseTimestamp?: string; repoName?: string; minimumConfidence?: MergeConfidence; From a730078b1f5ec4fe6d4b3d0d1a9738ab30ccc0fe Mon Sep 17 00:00:00 2001 From: Sergey Vedmak Date: Tue, 30 Nov 2021 13:34:54 +0300 Subject: [PATCH 8/9] rename type --- lib/workers/types.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/workers/types.ts b/lib/workers/types.ts index 2d5cd94f65e814..eeb658f305d3fd 100644 --- a/lib/workers/types.ts +++ b/lib/workers/types.ts @@ -16,9 +16,9 @@ import type { import type { PlatformPrOptions } from '../platform/types'; import type { File } from '../util/git/types'; import type { MergeConfidence } from '../util/merge-confidence'; -import type { ChangeLogNotes, ChangeLogResult } from './pr/changelog/types'; +import type { ChangeLogRelease, ChangeLogResult } from './pr/changelog/types'; -export type BranchUpgrade = Release & { releaseNotes?: ChangeLogNotes }; +export type ReleaseWithNotes = Release & Partial; export interface BranchUpgradeConfig extends Merge, @@ -52,7 +52,7 @@ export interface BranchUpgradeConfig prBodyTemplate?: string; prPriority?: number; prTitle?: string; - releases?: BranchUpgrade[]; + releases?: ReleaseWithNotes[]; releaseTimestamp?: string; repoName?: string; minimumConfidence?: MergeConfidence; From 8c8ad8f6b41999355c88a3d12e238f67c15c3147 Mon Sep 17 00:00:00 2001 From: Sergey Vedmak Date: Tue, 30 Nov 2021 18:58:09 +0300 Subject: [PATCH 9/9] modify test --- .../pr/__snapshots__/index.spec.ts.snap | 2 +- lib/workers/pr/index.spec.ts | 33 +++++++++++++++++++ lib/workers/pr/index.ts | 1 - 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/lib/workers/pr/__snapshots__/index.spec.ts.snap b/lib/workers/pr/__snapshots__/index.spec.ts.snap index 3a4d5a59433d7b..296ae0bf1cc9eb 100644 --- a/lib/workers/pr/__snapshots__/index.spec.ts.snap +++ b/lib/workers/pr/__snapshots__/index.spec.ts.snap @@ -137,7 +137,7 @@ Array [ "gitLabIgnoreApprovals": false, "usePlatformAutomerge": false, }, - "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | lockFileMaintenance | \`1.0.0\` -> \`1.1.0\` |\\n| a | | | \`zzzzzz\` -> \`aaaaaaa\` |\\n| b | | pin | \`some_old_value\` -> \`some_new_value\` |\\n| c | | | \`\` -> \`\` |\\n| d | | lockFileMaintenance | \`\` -> \`\` |\\n\\nnote 1\\n\\nnote 2\\n\\n:warning: Release Notes retrieval for this PR were skipped because no github.com credentials were available.\\nIf you are self-hosted, please see [this instruction](https://github.com/renovatebot/renovate/blob/master/docs/usage/examples/self-hosting.md#githubcom-token-for-release-notes).\\n\\nšŸ”” If you wish to disable git hash updates, add \`\\":disableDigestUpdates\\"\` to the extends array in your config.\\n\\nšŸ”§ This Pull Request updates lock files to use the latest dependency versions.\\n\\n---\\n\\n### Release Notes\\n\\n
\\nrenovateapp/dummy (dummy)\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n
\\nrenovateapp/dummy (b)\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n
\\nrenovateapp/dummy (c)\\n\\n
\\n\\n
\\nrenovateapp/dummy (d)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: At any time (no schedule defined).\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Never, or you tick the rebase/retry checkbox.\\n\\nšŸ‘» **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", + "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | lockFileMaintenance | \`1.0.0\` -> \`1.1.0\` |\\n| a | | | \`zzzzzz\` -> \`aaaaaaa\` |\\n| b | | pin | \`some_old_value\` -> \`some_new_value\` |\\n| c | | | \`\` -> \`\` |\\n| d | | lockFileMaintenance | \`\` -> \`\` |\\n| e | | lockFileMaintenance | \`\` -> \`\` |\\n| f | | lockFileMaintenance | \`\` -> \`\` |\\n\\nnote 1\\n\\nnote 2\\n\\n:warning: Release Notes retrieval for this PR were skipped because no github.com credentials were available.\\nIf you are self-hosted, please see [this instruction](https://github.com/renovatebot/renovate/blob/master/docs/usage/examples/self-hosting.md#githubcom-token-for-release-notes).\\n\\nšŸ”” If you wish to disable git hash updates, add \`\\":disableDigestUpdates\\"\` to the extends array in your config.\\n\\nšŸ”§ This Pull Request updates lock files to use the latest dependency versions.\\n\\n---\\n\\n### Release Notes\\n\\n
\\nrenovateapp/dummy (dummy)\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n
\\nrenovateapp/dummy (b)\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n
\\nrenovateapp/dummy (c)\\n\\n
\\n\\n
\\nrenovateapp/dummy (d)\\n\\n
\\n\\n
\\nrenovateapp/dummymonorepo\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: At any time (no schedule defined).\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Never, or you tick the rebase/retry checkbox.\\n\\nšŸ‘» **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, click this checkbox.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", "sourceBranch": "renovate/dummy-1.x", "targetBranch": undefined, diff --git a/lib/workers/pr/index.spec.ts b/lib/workers/pr/index.spec.ts index 2cd7adeec71b26..37aba8e8b15482 100644 --- a/lib/workers/pr/index.spec.ts +++ b/lib/workers/pr/index.spec.ts @@ -282,6 +282,7 @@ describe('workers/pr/index', () => { expect(platform.createPr).toHaveBeenCalled(); }); it('should create group PR', async () => { + const depsWithSameNotesSourceUrl = ['e', 'f']; config.upgrades = config.upgrades.concat([ { depName: 'a', @@ -305,12 +306,44 @@ describe('workers/pr/index', () => { updateType: 'lockFileMaintenance', prBodyNotes: ['{{#if foo}}'], }, + { + depName: depsWithSameNotesSourceUrl[0], + updateType: 'lockFileMaintenance', + prBodyNotes: ['{{#if foo}}'], + }, + { + depName: depsWithSameNotesSourceUrl[1], + updateType: 'lockFileMaintenance', + prBodyNotes: ['{{#if foo}}'], + }, ] as never); config.updateType = 'lockFileMaintenance'; config.recreateClosed = true; config.rebaseWhen = 'never'; for (const upgrade of config.upgrades) { upgrade.logJSON = await changelogHelper.getChangeLogJSON(upgrade); + + if (depsWithSameNotesSourceUrl.includes(upgrade.depName)) { + upgrade.sourceDirectory = `packages/${upgrade.depName}`; + + upgrade.logJSON = { + ...upgrade.logJSON, + project: { + ...upgrade.logJSON.project, + repository: 'renovateapp/dummymonorepo', + }, + versions: upgrade.logJSON.versions.map((V) => { + return { + ...V, + releaseNotes: { + ...V.releaseNotes, + notesSourceUrl: + 'https://github.com/renovateapp/dummymonorepo/blob/changelogfile.md', + }, + }; + }), + }; + } } const { pr } = await prWorker.ensurePr(config); expect(pr).toMatchObject({ displayNumber: 'New Pull Request' }); diff --git a/lib/workers/pr/index.ts b/lib/workers/pr/index.ts index 08073628647696..8ada26136c7f72 100644 --- a/lib/workers/pr/index.ts +++ b/lib/workers/pr/index.ts @@ -322,7 +322,6 @@ export async function ensurePr( const notesSourceUrl = upgrade.releases?.[0]?.releaseNotes?.notesSourceUrl || upgrade.sourceUrl; - // istanbul ignore if if (upgrade.hasReleaseNotes && notesSourceUrl) { if (releaseNotesSources.includes(notesSourceUrl)) { logger.debug(