Skip to content
Snippets Groups Projects
Unverified Commit 184a7755 authored by Martin Herndl's avatar Martin Herndl Committed by GitHub
Browse files

fix: improve re-opening behaviour of group updates (#13830)

parent ec4cf704
No related branches found
No related tags found
No related merge requests found
...@@ -224,6 +224,86 @@ describe('workers/repository/updates/generate', () => { ...@@ -224,6 +224,86 @@ describe('workers/repository/updates/generate', () => {
expect(res.groupName).toBeDefined(); expect(res.groupName).toBeDefined();
expect(res.releaseTimestamp).toBe('2017-02-08T20:01:41+00:00'); 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', () => { it('groups multiple digest updates', () => {
const branch = [ const branch = [
{ {
......
...@@ -73,6 +73,7 @@ export function generateBranchConfig( ...@@ -73,6 +73,7 @@ export function generateBranchConfig(
const depNames: string[] = []; const depNames: string[] = [];
const newValue: string[] = []; const newValue: string[] = [];
const toVersions: string[] = []; const toVersions: string[] = [];
const toValues = new Set<string>();
branchUpgrades.forEach((upg) => { branchUpgrades.forEach((upg) => {
if (!depNames.includes(upg.depName)) { if (!depNames.includes(upg.depName)) {
depNames.push(upg.depName); depNames.push(upg.depName);
...@@ -80,6 +81,7 @@ export function generateBranchConfig( ...@@ -80,6 +81,7 @@ export function generateBranchConfig(
if (!toVersions.includes(upg.newVersion)) { if (!toVersions.includes(upg.newVersion)) {
toVersions.push(upg.newVersion); toVersions.push(upg.newVersion);
} }
toValues.add(upg.newValue);
if (upg.commitMessageExtra) { if (upg.commitMessageExtra) {
const extra = template.compile(upg.commitMessageExtra, upg); const extra = template.compile(upg.commitMessageExtra, upg);
if (!newValue.includes(extra)) { if (!newValue.includes(extra)) {
...@@ -146,8 +148,9 @@ export function generateBranchConfig( ...@@ -146,8 +148,9 @@ export function generateBranchConfig(
delete upgrade.group; delete upgrade.group;
// istanbul ignore else // istanbul ignore else
if (toVersions.length > 1 && !typesGroup) { if (toVersions.length > 1 && toValues.size > 1 && !typesGroup) {
logger.trace({ toVersions }); logger.trace({ toVersions });
logger.trace({ toValues });
delete upgrade.commitMessageExtra; delete upgrade.commitMessageExtra;
upgrade.recreateClosed = true; upgrade.recreateClosed = true;
} else if (newValue.length > 1 && upgrade.isDigest) { } else if (newValue.length > 1 && upgrade.isDigest) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment