Skip to content

Commit

Permalink
fix: improve re-opening behaviour of group updates (#13830)
Browse files Browse the repository at this point in the history
  • Loading branch information
herndlm authored Jan 28, 2022
1 parent ec4cf70 commit 184a775
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 1 deletion.
80 changes: 80 additions & 0 deletions lib/workers/repository/updates/generate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down
5 changes: 4 additions & 1 deletion lib/workers/repository/updates/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ export function generateBranchConfig(
const depNames: string[] = [];
const newValue: string[] = [];
const toVersions: string[] = [];
const toValues = new Set<string>();
branchUpgrades.forEach((upg) => {
if (!depNames.includes(upg.depName)) {
depNames.push(upg.depName);
}
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)) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 184a775

Please sign in to comment.