diff --git a/lib/workers/repository/updates/generate.spec.ts b/lib/workers/repository/updates/generate.spec.ts index ffff612fca4394..6a238e7efb336f 100644 --- a/lib/workers/repository/updates/generate.spec.ts +++ b/lib/workers/repository/updates/generate.spec.ts @@ -224,6 +224,86 @@ describe('workers/repository/updates/generate', () => { expect(res.groupName).toBeDefined(); expect(res.releaseTimestamp).toBe('2017-02-08T20:01:41+00:00'); }); + it('groups multiple upgrades different version but same value', () => { + const branch = [ + { + depName: 'depB', + groupName: 'some-group', + branchName: 'some-branch', + prTitle: 'some-title', + commitMessageExtra: + 'to {{#if isMajor}}v{{newMajor}}{{else}}{{#unless isRange}}v{{/unless}}{{newValue}}{{/if}}', + foo: 1, + newValue: '^6.0', + newVersion: '6.0.3', + group: { + foo: 2, + }, + releaseTimestamp: '2017-02-07T20:01:41+00:00', + }, + { + depName: 'depA', + groupName: 'some-group', + branchName: 'some-branch', + prTitle: 'some-title', + commitMessageExtra: + 'to {{#if isMajor}}v{{newMajor}}{{else}}{{#unless isRange}}v{{/unless}}{{newValue}}{{/if}}', + foo: 1, + newValue: '^6.0', + newVersion: '6.0.1', + group: { + foo: 2, + }, + releaseTimestamp: '2017-02-08T20:01:41+00:00', + }, + ]; + const res = generateBranchConfig(branch); + expect(res.foo).toBe(2); + expect(res.singleVersion).toBeUndefined(); + expect(res.recreateClosed).toBeUndefined(); + expect(res.groupName).toBeDefined(); + expect(res.releaseTimestamp).toBe('2017-02-08T20:01:41+00:00'); + }); + it('groups multiple upgrades different value but same version', () => { + const branch = [ + { + depName: 'depB', + groupName: 'some-group', + branchName: 'some-branch', + prTitle: 'some-title', + commitMessageExtra: + 'to {{#if isMajor}}v{{newMajor}}{{else}}{{#unless isRange}}v{{/unless}}{{newValue}}{{/if}}', + foo: 1, + newValue: '^6.0.1', + newVersion: '6.0.2', + group: { + foo: 2, + }, + releaseTimestamp: '2017-02-07T20:01:41+00:00', + }, + { + depName: 'depA', + groupName: 'some-group', + branchName: 'some-branch', + prTitle: 'some-title', + commitMessageExtra: + 'to {{#if isMajor}}v{{newMajor}}{{else}}{{#unless isRange}}v{{/unless}}{{newValue}}{{/if}}', + foo: 1, + newValue: '^6.0.0', + newVersion: '6.0.2', + group: { + foo: 2, + }, + releaseTimestamp: '2017-02-08T20:01:41+00:00', + }, + ]; + const res = generateBranchConfig(branch); + expect(res.foo).toBe(2); + expect(res.singleVersion).toBeUndefined(); + expect(res.recreateClosed).toBeUndefined(); + expect(res.groupName).toBeDefined(); + expect(res.releaseTimestamp).toBe('2017-02-08T20:01:41+00:00'); + }); it('groups multiple digest updates', () => { const branch = [ { diff --git a/lib/workers/repository/updates/generate.ts b/lib/workers/repository/updates/generate.ts index 2dc8c19c13b2eb..26dd516895d4f7 100644 --- a/lib/workers/repository/updates/generate.ts +++ b/lib/workers/repository/updates/generate.ts @@ -73,6 +73,7 @@ export function generateBranchConfig( const depNames: string[] = []; const newValue: string[] = []; const toVersions: string[] = []; + const toValues = new Set(); branchUpgrades.forEach((upg) => { if (!depNames.includes(upg.depName)) { depNames.push(upg.depName); @@ -80,6 +81,7 @@ export function generateBranchConfig( if (!toVersions.includes(upg.newVersion)) { toVersions.push(upg.newVersion); } + toValues.add(upg.newValue); if (upg.commitMessageExtra) { const extra = template.compile(upg.commitMessageExtra, upg); if (!newValue.includes(extra)) { @@ -146,8 +148,9 @@ export function generateBranchConfig( delete upgrade.group; // istanbul ignore else - if (toVersions.length > 1 && !typesGroup) { + if (toVersions.length > 1 && toValues.size > 1 && !typesGroup) { logger.trace({ toVersions }); + logger.trace({ toValues }); delete upgrade.commitMessageExtra; upgrade.recreateClosed = true; } else if (newValue.length > 1 && upgrade.isDigest) {