Skip to content

Commit

Permalink
fix(pr): monorepo changelog with sourceDirectory (#13366)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanitete committed Jan 28, 2022
1 parent c34c1a7 commit c4af347
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/workers/pr/__snapshots__/index.spec.ts.snap
Expand Up @@ -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| 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<details>\\n<summary>renovateapp/dummy (dummy)</summary>\\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</details>\\n\\n<details>\\n<summary>renovateapp/dummy (b)</summary>\\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</details>\\n\\n<details>\\n<summary>renovateapp/dummymonorepo</summary>\\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</details>\\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 - [ ] <!-- rebase-check -->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| g | | lockFileMaintenance | \`\` -> \`\` |\\n| h | | 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<details>\\n<summary>renovateapp/dummy (dummy)</summary>\\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</details>\\n\\n<details>\\n<summary>renovateapp/dummy (b)</summary>\\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</details>\\n\\n<details>\\n<summary>renovateapp/dummymonorepo</summary>\\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</details>\\n\\n<details>\\n<summary>renovateapp/anotherdummymonorepo (g)</summary>\\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</details>\\n\\n<details>\\n<summary>renovateapp/anotherdummymonorepo (h)</summary>\\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</details>\\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 - [ ] <!-- rebase-check -->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,
Expand Down
32 changes: 32 additions & 0 deletions lib/workers/pr/index.spec.ts
Expand Up @@ -291,6 +291,7 @@ describe('workers/pr/index', () => {
});
it('should create group PR', async () => {
const depsWithSameNotesSourceUrl = ['e', 'f'];
const depsWithSameSourceUrl = ['g', 'h'];
config.upgrades = config.upgrades.concat([
{
depName: 'a',
Expand Down Expand Up @@ -324,6 +325,16 @@ describe('workers/pr/index', () => {
updateType: 'lockFileMaintenance',
prBodyNotes: ['{{#if foo}}'],
},
{
depName: depsWithSameSourceUrl[0],
updateType: 'lockFileMaintenance',
prBodyNotes: ['{{#if foo}}'],
},
{
depName: depsWithSameSourceUrl[1],
updateType: 'lockFileMaintenance',
prBodyNotes: ['{{#if foo}}'],
},
] as never);
config.updateType = 'lockFileMaintenance';
config.recreateClosed = true;
Expand Down Expand Up @@ -352,6 +363,27 @@ describe('workers/pr/index', () => {
}),
};
}

if (depsWithSameSourceUrl.includes(upgrade.depName)) {
upgrade.sourceDirectory = `packages/${upgrade.depName}`;

upgrade.logJSON = {
...upgrade.logJSON,
project: {
...upgrade.logJSON.project,
repository: 'renovateapp/anotherdummymonorepo',
},
versions: upgrade.logJSON.versions.map((V) => {
return {
...V,
releaseNotes: {
...V.releaseNotes,
notesSourceUrl: null,
},
};
}),
};
}
}
const { pr } = await prWorker.ensurePr(config);
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
Expand Down
8 changes: 6 additions & 2 deletions lib/workers/pr/index.ts
Expand Up @@ -328,8 +328,12 @@ export async function ensurePr(

const releaseNotesSources: string[] = [];
for (const upgrade of config.upgrades) {
const notesSourceUrl =
upgrade.releases?.[0]?.releaseNotes?.notesSourceUrl || upgrade.sourceUrl;
let notesSourceUrl = upgrade.releases?.[0]?.releaseNotes?.notesSourceUrl;
if (!notesSourceUrl) {
notesSourceUrl = `${upgrade.sourceUrl}${
upgrade.sourceDirectory ? `:${upgrade.sourceDirectory}` : ''
}`;
}

if (upgrade.hasReleaseNotes && notesSourceUrl) {
if (releaseNotesSources.includes(notesSourceUrl)) {
Expand Down

0 comments on commit c4af347

Please sign in to comment.