diff --git a/lib/workers/pr/__snapshots__/index.spec.ts.snap b/lib/workers/pr/__snapshots__/index.spec.ts.snap index 7ff26d4911972d..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\\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| 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/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 35521b9872be84..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.repoName}} +{{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 f365fde6e9a468..3f84a9cade2810 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@v2-${project.repository}${ + project.sourceDirectory ? `-${project.sourceDirectory}` : '' + }-${project.apiBaseUrl}`; const cachedResult = memCache.get>(cacheKey); // istanbul ignore if if (cachedResult !== undefined) { @@ -258,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 { @@ -273,6 +278,7 @@ export async function getReleaseNotesMd( return { body, url, + notesSourceUrl, }; } } @@ -320,10 +326,12 @@ export async function addReleaseNotes( return input; } const output: ChangeLogResult = { ...input, versions: [] }; - const repository = input.project.repository; - const cacheNamespace = `changelog-${input.project.type}-notes`; + const { repository, sourceDirectory } = input.project; + const cacheNamespace = `changelog-${input.project.type}-notes@v2`; function getCacheKey(version: string): string { - return `${repository}:${version}`; + return `${repository}:${ + sourceDirectory ? `${sourceDirectory}:` : '' + }${version}`; } for (const v of input.versions) { let releaseNotes: ChangeLogNotes; @@ -338,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.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 c6b78986057b49..8ada26136c7f72 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'; @@ -260,6 +260,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}-${ @@ -282,9 +290,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 }; @@ -309,17 +317,20 @@ export async function ensurePr( config.hasReleaseNotes = config.upgrades.some((upg) => upg.hasReleaseNotes); - const releaseNoteRepos: string[] = []; + const releaseNotesSources: string[] = []; for (const upgrade of config.upgrades) { - if (upgrade.hasReleaseNotes) { - if (releaseNoteRepos.includes(upgrade.sourceUrl)) { + const notesSourceUrl = + upgrade.releases?.[0]?.releaseNotes?.notesSourceUrl || upgrade.sourceUrl; + + if (upgrade.hasReleaseNotes && notesSourceUrl) { + if (releaseNotesSources.includes(notesSourceUrl)) { logger.debug( { depName: upgrade.depName }, 'Removing duplicate release notes' ); upgrade.hasReleaseNotes = false; } else { - releaseNoteRepos.push(upgrade.sourceUrl); + releaseNotesSources.push(notesSourceUrl); } } } diff --git a/lib/workers/types.ts b/lib/workers/types.ts index 02e0c5a44f4453..eeb658f305d3fd 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 { ChangeLogRelease, ChangeLogResult } from './pr/changelog/types'; + +export type ReleaseWithNotes = Release & Partial; export interface BranchUpgradeConfig extends Merge, @@ -50,7 +52,7 @@ export interface BranchUpgradeConfig prBodyTemplate?: string; prPriority?: number; prTitle?: string; - releases?: Release[]; + releases?: ReleaseWithNotes[]; releaseTimestamp?: string; repoName?: string; minimumConfidence?: MergeConfidence; @@ -61,6 +63,7 @@ export interface BranchUpgradeConfig logJSON?: ChangeLogResult; + hasReleaseNotes?: boolean; homepage?: string; changelogUrl?: string; dependencyUrl?: string;