Skip to content
Snippets Groups Projects
Commit bdf1227b authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix: better group commit extra detection

parent ad605423
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,7 @@ function generateBranchConfig(branchUpgrades) { ...@@ -13,6 +13,7 @@ function generateBranchConfig(branchUpgrades) {
logger.debug(`hasGroupName: ${hasGroupName}`); logger.debug(`hasGroupName: ${hasGroupName}`);
// Use group settings only if multiple upgrades or lazy grouping is disabled // Use group settings only if multiple upgrades or lazy grouping is disabled
const depNames = []; const depNames = [];
const newValue = [];
const toVersions = []; const toVersions = [];
branchUpgrades.forEach(upg => { branchUpgrades.forEach(upg => {
if (!depNames.includes(upg.depName)) { if (!depNames.includes(upg.depName)) {
...@@ -21,12 +22,18 @@ function generateBranchConfig(branchUpgrades) { ...@@ -21,12 +22,18 @@ function generateBranchConfig(branchUpgrades) {
if (!toVersions.includes(upg.toVersion)) { if (!toVersions.includes(upg.toVersion)) {
toVersions.push(upg.toVersion); toVersions.push(upg.toVersion);
} }
if (upg.commitMessageExtra) {
const extra = handlebars.compile(upg.commitMessageExtra)(upg);
if (!newValue.includes(extra)) {
newValue.push(extra);
}
}
}); });
const groupEligible = const groupEligible =
depNames.length > 1 || depNames.length > 1 ||
toVersions.length > 1 || toVersions.length > 1 ||
branchUpgrades[0].lazyGrouping === false; branchUpgrades[0].lazyGrouping === false;
if (branchUpgrades.length > 1 && !groupEligible) { if (newValue.length > 1 && !groupEligible) {
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
branchUpgrades[0].commitMessageExtra = `to v${toVersions[0]}`; branchUpgrades[0].commitMessageExtra = `to v${toVersions[0]}`;
} }
......
...@@ -165,6 +165,45 @@ describe('workers/repository/updates/generate', () => { ...@@ -165,6 +165,45 @@ describe('workers/repository/updates/generate', () => {
expect(res.groupName).toBeDefined(); expect(res.groupName).toBeDefined();
expect(res.releaseTimestamp).toEqual('2017-02-08T20:01:41+00:00'); expect(res.releaseTimestamp).toEqual('2017-02-08T20:01:41+00:00');
}); });
it('fixes different messages', () => {
const branch = [
{
depName: 'depA',
groupName: 'some-group',
branchName: 'some-branch',
prTitle: 'some-title',
commitMessageExtra:
'to {{#if isMajor}}v{{newMajor}}{{else}}{{#unless isRange}}v{{/unless}}{{newValue}}{{/if}}',
lazyGrouping: true,
foo: 1,
newValue: '>= 5.1.2',
toVersion: '5.1.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}}',
lazyGrouping: true,
foo: 1,
newValue: '^5,1,2',
toVersion: '5.1.2',
group: {
foo: 2,
},
releaseTimestamp: '2017-02-08T20:01:41+00:00',
},
];
const res = generateBranchConfig(branch);
expect(res.foo).toBe(1);
expect(res.groupName).toBeUndefined();
});
it('uses semantic commits', () => { it('uses semantic commits', () => {
const branch = [ const branch = [
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment