diff --git a/docs/configuration.md b/docs/configuration.md index 50799574ce27847fd48f8cbb6c404bcfbad1f893..367176031eb8ec46b2683ce5611b1096bb897a4f 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -707,10 +707,9 @@ location with this method. <td>Config if groupName is enabled</td> <td>json</td> <td><pre>{ - "recreateClosed": true, "branchName": "{{branchPrefix}}{{groupSlug}}", - "prTitle": "Renovate {{groupName}} packages", "commitMessage": "Update {{groupName}} packages", + "prTitle": "Update {{groupName}} packages{{#if singleVersion}} to {{#unless isRange}}v{{/unless}}{{singleVersion}}{{/if}}", "prBody": "This Pull Request renovates the package group \"{{groupName}}\".\n\n{{#if schedule}}\n**Note**: This PR was created on a configured schedule (\"{{schedule}}\"{{#if timezone}} in timezone `{{timezone}}`{{/if}}) and will not receive updates outside those times.\n{{/if}}\n\n{{#each upgrades as |upgrade|}}\n- {{#if repositoryUrl}}[{{upgrade.depName}}]({{upgrade.repositoryUrl}}){{else}}{{depName}}{{/if}}: from `{{upgrade.currentVersion}}` to `{{upgrade.newVersion}}`\n{{/each}}\n\n{{#unless isPin}}\n### Commits\n\n{{#each upgrades as |upgrade|}}\n{{#if upgrade.releases.length}}\n<details>\n<summary>{{upgrade.githubName}}</summary>\n{{#each upgrade.releases as |release|}}\n\n#### {{release.version}}\n{{#each release.commits as |commit|}}\n- [`{{commit.shortSha}}`]({{commit.url}}){{commit.message}}\n{{/each}}\n{{/each}}\n\n</details>\n{{/if}}\n{{/each}}\n{{/unless}}\n<br />\n\n{{#if hasErrors}}\n\n---\n\n### Errors\n\nRenovate encountered some errors when processing your repository, so you are being notified here even if they do not directly apply to this PR.\n\n{{#each errors as |error|}}\n- `{{error.depName}}`: {{error.message}}\n{{/each}}\n{{/if}}\n\n{{#if hasWarnings}}\n\n---\n\n### Warnings\n\nPlease make sure the following warnings are safe to ignore:\n\n{{#each warnings as |warning|}}\n- `{{warning.depName}}`: {{warning.message}}\n{{/each}}\n{{/if}}\n\n---\n\nThis PR has been generated by [Renovate Bot](https://renovateapp.com)." }</pre></td> <td></td> diff --git a/lib/config/definitions.js b/lib/config/definitions.js index ecd73e3a5deb6cb0f5c49bb4f351d619b0d381a8..8ed29d400c64ecc26e79260f1d11ab85705f00da 100644 --- a/lib/config/definitions.js +++ b/lib/config/definitions.js @@ -596,7 +596,6 @@ const options = [ description: 'Config if groupName is enabled', type: 'json', default: { - recreateClosed: true, branchName: template('branchName', 'group'), commitMessage: template('commitMessage', 'group'), prTitle: template('prTitle', 'group'), diff --git a/lib/config/templates/group/pr-title.hbs b/lib/config/templates/group/pr-title.hbs index c30dd38dccc9388847356f56bf1576c893d2dffe..9f8028e5298e865e1b9f762af603a310bda23148 100644 --- a/lib/config/templates/group/pr-title.hbs +++ b/lib/config/templates/group/pr-title.hbs @@ -1 +1 @@ -Update {{groupName}} packages +Update {{groupName}} packages{{#if singleVersion}} to {{#unless isRange}}v{{/unless}}{{singleVersion}}{{/if}} diff --git a/lib/workers/repository/updates/generate.js b/lib/workers/repository/updates/generate.js index 2bba5590ddb8cdac1539e9f4326e90b41d9c4abd..8c405e3c30eb0744e786d06c9c752d35e8a6cd5e 100644 --- a/lib/workers/repository/updates/generate.js +++ b/lib/workers/repository/updates/generate.js @@ -8,10 +8,14 @@ function generateBranchConfig(branchUpgrades) { logger.debug(`hasGroupName: ${hasGroupName}`); // Use group settings only if multiple upgrades or lazy grouping is disabled const depNames = []; + const newVersions = []; branchUpgrades.forEach(upg => { if (!depNames.includes(upg.depName)) { depNames.push(upg.depName); } + if (!newVersions.includes(upg.newVersion)) { + newVersions.push(upg.newVersion); + } }); const groupEligible = depNames.length > 1 || branchUpgrades[0].lazyGrouping === false; @@ -29,6 +33,11 @@ function generateBranchConfig(branchUpgrades) { // Delete group config regardless of whether it was applied delete upgrade.group; delete upgrade.lazyGrouping; + if (newVersions.length === 1) { + [upgrade.singleVersion] = newVersions; + } else { + upgrade.recreateClosed = true; + } // Use templates to generate strings logger.debug( { branchName: upgrade.branchName, prTitle: upgrade.prTitle }, diff --git a/test/manager/__snapshots__/resolve.spec.js.snap b/test/manager/__snapshots__/resolve.spec.js.snap index afcdc1fbd97994893a5019600363539a866747f6..2a23352d6f5f140c3344248daa20d706ff6afac6 100644 --- a/test/manager/__snapshots__/resolve.spec.js.snap +++ b/test/manager/__snapshots__/resolve.spec.js.snap @@ -307,8 +307,7 @@ Please make sure the following warnings are safe to ignore: --- This PR has been generated by [Renovate Bot](https://renovateapp.com).", - "prTitle": "Update {{groupName}} packages", - "recreateClosed": true, + "prTitle": "Update {{groupName}} packages{{#if singleVersion}} to {{#unless isRange}}v{{/unless}}{{singleVersion}}{{/if}}", }, "groupName": null, "groupSlug": null, @@ -833,8 +832,7 @@ Please make sure the following warnings are safe to ignore: --- This PR has been generated by [Renovate Bot](https://renovateapp.com).", - "prTitle": "Update {{groupName}} packages", - "recreateClosed": true, + "prTitle": "Update {{groupName}} packages{{#if singleVersion}} to {{#unless isRange}}v{{/unless}}{{singleVersion}}{{/if}}", }, "groupName": null, "groupSlug": null, @@ -1369,8 +1367,7 @@ Please make sure the following warnings are safe to ignore: --- This PR has been generated by [Renovate Bot](https://renovateapp.com).", - "prTitle": "Update {{groupName}} packages", - "recreateClosed": true, + "prTitle": "Update {{groupName}} packages{{#if singleVersion}} to {{#unless isRange}}v{{/unless}}{{singleVersion}}{{/if}}", }, "groupName": null, "groupSlug": null, @@ -2163,8 +2160,7 @@ Please make sure the following warnings are safe to ignore: --- This PR has been generated by [Renovate Bot](https://renovateapp.com).", - "prTitle": "Update {{groupName}} packages", - "recreateClosed": true, + "prTitle": "Update {{groupName}} packages{{#if singleVersion}} to {{#unless isRange}}v{{/unless}}{{singleVersion}}{{/if}}", }, "groupName": null, "groupSlug": null, @@ -2696,8 +2692,7 @@ Please make sure the following warnings are safe to ignore: --- This PR has been generated by [Renovate Bot](https://renovateapp.com).", - "prTitle": "Update {{groupName}} packages", - "recreateClosed": true, + "prTitle": "Update {{groupName}} packages{{#if singleVersion}} to {{#unless isRange}}v{{/unless}}{{singleVersion}}{{/if}}", }, "groupName": null, "groupSlug": null, @@ -3220,8 +3215,7 @@ Please make sure the following warnings are safe to ignore: --- This PR has been generated by [Renovate Bot](https://renovateapp.com).", - "prTitle": "Update {{groupName}} packages", - "recreateClosed": true, + "prTitle": "Update {{groupName}} packages{{#if singleVersion}} to {{#unless isRange}}v{{/unless}}{{singleVersion}}{{/if}}", }, "groupName": null, "groupSlug": null, @@ -3753,8 +3747,7 @@ Please make sure the following warnings are safe to ignore: --- This PR has been generated by [Renovate Bot](https://renovateapp.com).", - "prTitle": "Update {{groupName}} packages", - "recreateClosed": true, + "prTitle": "Update {{groupName}} packages{{#if singleVersion}} to {{#unless isRange}}v{{/unless}}{{singleVersion}}{{/if}}", }, "groupName": null, "groupSlug": null, diff --git a/test/workers/package/__snapshots__/index.spec.js.snap b/test/workers/package/__snapshots__/index.spec.js.snap index 8008d812107dcbaeb2e548a07763b6380204f756..00358f87390b6ab24593f6cc1c46838c449d59f8 100644 --- a/test/workers/package/__snapshots__/index.spec.js.snap +++ b/test/workers/package/__snapshots__/index.spec.js.snap @@ -78,7 +78,6 @@ Please make sure the following warnings are safe to ignore: This PR has been generated by [Renovate Bot](https://renovateapp.com).", "prTitle": "{{groupName}}", - "recreateClosed": true, }, "groupName": "Pin Dependencies", "groupSlug": null, diff --git a/test/workers/repository/updates/__snapshots__/branchify.spec.js.snap b/test/workers/repository/updates/__snapshots__/branchify.spec.js.snap index 7e00c0deb14e316b6f197b056aabaa225a642acd..1f754fb6f3201eecd2426df2aa7f5e7708ed1d00 100644 --- a/test/workers/repository/updates/__snapshots__/branchify.spec.js.snap +++ b/test/workers/repository/updates/__snapshots__/branchify.spec.js.snap @@ -18,11 +18,13 @@ Object { "branchName": "foo-1.1.0", "depName": "foo", "prTitle": "some-title", + "singleVersion": undefined, "upgrades": Array [ Object { "branchName": "foo-1.1.0", "depName": "foo", "prTitle": "some-title", + "singleVersion": undefined, "version": "1.1.0", }, ], @@ -32,11 +34,13 @@ Object { "branchName": "foo-2.0.0", "depName": "foo", "prTitle": "some-title", + "singleVersion": undefined, "upgrades": Array [ Object { "branchName": "foo-2.0.0", "depName": "foo", "prTitle": "some-title", + "singleVersion": undefined, "version": "2.0.0", }, ], @@ -46,11 +50,13 @@ Object { "branchName": "bar-1.1.0", "depName": "bar", "prTitle": "some-title", + "singleVersion": undefined, "upgrades": Array [ Object { "branchName": "bar-1.1.0", "depName": "bar", "prTitle": "some-title", + "singleVersion": undefined, "version": "1.1.0", }, ], @@ -347,8 +353,7 @@ Please make sure the following warnings are safe to ignore: --- This PR has been generated by [Renovate Bot](https://renovateapp.com).", - "prTitle": "Update {{groupName}} packages", - "recreateClosed": true, + "prTitle": "Update {{groupName}} packages{{#if singleVersion}} to {{#unless isRange}}v{{/unless}}{{singleVersion}}{{/if}}", }, "groupName": null, "groupSlug": null, @@ -587,17 +592,20 @@ Object { "branchName": "foo", "depName": "foo", "prTitle": "some-title", + "singleVersion": undefined, "upgrades": Array [ Object { "branchName": "foo", "depName": "foo", "prTitle": "some-title", + "singleVersion": undefined, "version": "2.0.0", }, Object { "branchName": "foo", "depName": "foo", "prTitle": "some-title", + "singleVersion": undefined, "version": "1.1.0", }, ], @@ -607,11 +615,13 @@ Object { "branchName": "bar-1.1.0", "depName": "bar", "prTitle": "some-title", + "singleVersion": undefined, "upgrades": Array [ Object { "branchName": "bar-1.1.0", "depName": "bar", "prTitle": "some-title", + "singleVersion": undefined, "version": "1.1.0", }, ], @@ -908,8 +918,7 @@ Please make sure the following warnings are safe to ignore: --- This PR has been generated by [Renovate Bot](https://renovateapp.com).", - "prTitle": "Update {{groupName}} packages", - "recreateClosed": true, + "prTitle": "Update {{groupName}} packages{{#if singleVersion}} to {{#unless isRange}}v{{/unless}}{{singleVersion}}{{/if}}", }, "groupName": null, "groupSlug": null, @@ -1150,6 +1159,7 @@ Object { "groupName": "My Group", "groupSlug": "my-group", "prTitle": "some-title", + "singleVersion": undefined, "upgrades": Array [ Object { "branchName": "renovate/my-group", @@ -1157,6 +1167,7 @@ Object { "groupName": "My Group", "groupSlug": "my-group", "prTitle": "some-title", + "singleVersion": undefined, "version": "1.1.0", }, Object { @@ -1165,6 +1176,7 @@ Object { "groupName": "My Group", "groupSlug": "my-group", "prTitle": "some-title", + "singleVersion": undefined, "version": "1.1.0", }, ], @@ -1174,11 +1186,13 @@ Object { "branchName": "foo", "depName": "foo", "prTitle": "some-title", + "singleVersion": undefined, "upgrades": Array [ Object { "branchName": "foo", "depName": "foo", "prTitle": "some-title", + "singleVersion": undefined, "version": "2.0.0", }, ], @@ -1475,8 +1489,7 @@ Please make sure the following warnings are safe to ignore: --- This PR has been generated by [Renovate Bot](https://renovateapp.com).", - "prTitle": "Update {{groupName}} packages", - "recreateClosed": true, + "prTitle": "Update {{groupName}} packages{{#if singleVersion}} to {{#unless isRange}}v{{/unless}}{{singleVersion}}{{/if}}", }, "groupName": null, "groupSlug": null, @@ -1714,10 +1727,12 @@ Object { Object { "branchName": "foo-1.1.0", "prTitle": "some-title", + "singleVersion": undefined, "upgrades": Array [ Object { "branchName": "foo-1.1.0", "prTitle": "some-title", + "singleVersion": undefined, "version": "1.1.0", }, ], @@ -1726,10 +1741,12 @@ Object { Object { "branchName": "bar-1.1.0", "prTitle": "some-title", + "singleVersion": undefined, "upgrades": Array [ Object { "branchName": "bar-1.1.0", "prTitle": "some-title", + "singleVersion": undefined, "version": "1.1.0", }, ], @@ -2030,8 +2047,7 @@ Please make sure the following warnings are safe to ignore: --- This PR has been generated by [Renovate Bot](https://renovateapp.com).", - "prTitle": "Update {{groupName}} packages", - "recreateClosed": true, + "prTitle": "Update {{groupName}} packages{{#if singleVersion}} to {{#unless isRange}}v{{/unless}}{{singleVersion}}{{/if}}", }, "groupName": null, "groupSlug": null, @@ -2279,11 +2295,13 @@ Object { "branchName": "foo-1.1.0", "depName": "foo", "prTitle": "some-title", + "singleVersion": undefined, "upgrades": Array [ Object { "branchName": "foo-1.1.0", "depName": "foo", "prTitle": "some-title", + "singleVersion": undefined, "version": "1.1.0", }, ], @@ -2580,8 +2598,7 @@ Please make sure the following warnings are safe to ignore: --- This PR has been generated by [Renovate Bot](https://renovateapp.com).", - "prTitle": "Update {{groupName}} packages", - "recreateClosed": true, + "prTitle": "Update {{groupName}} packages{{#if singleVersion}} to {{#unless isRange}}v{{/unless}}{{singleVersion}}{{/if}}", }, "groupName": null, "groupSlug": null, diff --git a/test/workers/repository/updates/generate.spec.js b/test/workers/repository/updates/generate.spec.js index 99ad7f054429f30166e07436344bf446f317443e..fce6db8d031abc156c069c9ab02c039b60688589 100644 --- a/test/workers/repository/updates/generate.spec.js +++ b/test/workers/repository/updates/generate.spec.js @@ -73,7 +73,7 @@ describe('workers/repository/updates/generate', () => { expect(res.foo).toBe(1); expect(res.groupName).toBeUndefined(); }); - it('groups multiple upgrades', () => { + it('groups multiple upgrades same version', () => { const branch = [ { depName: 'some-dep', @@ -82,6 +82,7 @@ describe('workers/repository/updates/generate', () => { prTitle: 'some-title', lazyGrouping: true, foo: 1, + newVersion: '5.1.2', group: { foo: 2, }, @@ -93,6 +94,7 @@ describe('workers/repository/updates/generate', () => { prTitle: 'some-title', lazyGrouping: true, foo: 1, + newVersion: '5.1.2', group: { foo: 2, }, @@ -100,6 +102,40 @@ describe('workers/repository/updates/generate', () => { ]; const res = generateBranchConfig(branch); expect(res.foo).toBe(2); + expect(res.singleVersion).toBeDefined(); + expect(res.groupName).toBeDefined(); + }); + it('groups multiple upgrades different version', () => { + const branch = [ + { + depName: 'some-dep', + groupName: 'some-group', + branchName: 'some-branch', + prTitle: 'some-title', + lazyGrouping: true, + foo: 1, + newVersion: '5.1.2', + group: { + foo: 2, + }, + }, + { + depName: 'some-other-dep', + groupName: 'some-group', + branchName: 'some-branch', + prTitle: 'some-title', + lazyGrouping: true, + foo: 1, + newVersion: '1.1.0', + group: { + foo: 2, + }, + }, + ]; + const res = generateBranchConfig(branch); + expect(res.foo).toBe(2); + expect(res.singleVersion).toBeUndefined(); + expect(res.recreateClosed).toBe(true); expect(res.groupName).toBeDefined(); }); it('uses semantic commits', () => {