diff --git a/lib/workers/repository/process/lookup/index.js b/lib/workers/repository/process/lookup/index.js index 70e524294fbe6eafcab82d0469beaa31d38ddbf1..54205c6d6af7019ba08d58ab6c0ea29dde973795 100644 --- a/lib/workers/repository/process/lookup/index.js +++ b/lib/workers/repository/process/lookup/index.js @@ -26,7 +26,7 @@ async function lookupUpdates(config) { matches, getNewValue, } = versioning(config.versionScheme); - const res = { updates: [] }; + const res = { updates: [], warnings: [] }; if (isValid(currentValue)) { const dependency = await getDependency(config.purl, config); if (!dependency) { @@ -40,10 +40,9 @@ async function lookupUpdates(config) { result.message ); // TODO: return warnings in own field - res.updates.push(result); + res.warnings.push(result); return res; } - logger.debug({ dependency }); // istanbul ignore if if (dependency.deprecationMessage) { logger.info('Setting deprecationMessage'); @@ -72,7 +71,7 @@ async function lookupUpdates(config) { const rollback = getRollbackUpdate(config, allVersions); // istanbul ignore if if (!rollback) { - res.updates.push([ + res.warnings.push([ { updateType: 'warning', message: `Can't find version matching ${currentValue} for ${depName}`, diff --git a/lib/workers/repository/updates/branchify.js b/lib/workers/repository/updates/branchify.js index 137406d16563b6a9fb913766c78ee80e10e232c1..5d009a06cb404299927542e543c4a82adfda29af 100644 --- a/lib/workers/repository/updates/branchify.js +++ b/lib/workers/repository/updates/branchify.js @@ -31,48 +31,40 @@ function branchifyUpgrades(config, packageFiles) { const branches = []; for (const u of updates) { const update = { ...u }; - // Split out errors and warnings first - if (update.updateType === 'error') { - errors.push(update); - } else if (update.updateType === 'warning') { - warnings.push(update); + // Massage legacy vars just in case + update.currentVersion = update.currentValue; + update.newVersion = update.newValue; + // massage for handlebars + const upper = str => str.charAt(0).toUpperCase() + str.substr(1); + if (update.updateType) { + update[`is${upper(update.updateType)}`] = true; + } + // Check whether to use a group name + if (update.groupName) { + logger.debug('Using group branchName template'); + logger.debug( + `Dependency ${update.depName} is part of group ${update.groupName}` + ); + update.groupSlug = slugify(update.groupSlug || update.groupName, { + lower: true, + }); + update.branchTopic = update.group.branchTopic || update.branchTopic; + update.branchName = handlebars.compile( + update.group.branchName || update.branchName + )(update); } else { - // Massage legacy vars just in case - update.currentVersion = update.currentValue; - update.newVersion = update.newValue; - // massage for handlebars - const upper = str => str.charAt(0).toUpperCase() + str.substr(1); - if (update.updateType) { - update[`is${upper(update.updateType)}`] = true; - } - // Check whether to use a group name - if (update.groupName) { - logger.debug('Using group branchName template'); - logger.debug( - `Dependency ${update.depName} is part of group ${update.groupName}` - ); - update.groupSlug = slugify(update.groupSlug || update.groupName, { - lower: true, - }); - update.branchTopic = update.group.branchTopic || update.branchTopic; - update.branchName = handlebars.compile( - update.group.branchName || update.branchName - )(update); - } else { - update.branchName = handlebars.compile(update.branchName)(update); - } - // Compile extra times in case of nested handlebars templates update.branchName = handlebars.compile(update.branchName)(update); - update.branchName = cleanBranchName( - handlebars.compile(update.branchName)(update) - ); - - branchUpgrades[update.branchName] = - branchUpgrades[update.branchName] || []; - branchUpgrades[update.branchName] = [update].concat( - branchUpgrades[update.branchName] - ); } + // Compile extra times in case of nested handlebars templates + update.branchName = handlebars.compile(update.branchName)(update); + update.branchName = cleanBranchName( + handlebars.compile(update.branchName)(update) + ); + + branchUpgrades[update.branchName] = branchUpgrades[update.branchName] || []; + branchUpgrades[update.branchName] = [update].concat( + branchUpgrades[update.branchName] + ); } logger.debug(`Returning ${Object.keys(branchUpgrades).length} branch(es)`); for (const branchName of Object.keys(branchUpgrades)) { diff --git a/test/workers/repository/process/lookup/__snapshots__/index.spec.js.snap b/test/workers/repository/process/lookup/__snapshots__/index.spec.js.snap index 722dfa265b8ca8497bb2b901adde74e92bb2cb3c..2b079c41461b344f36b9956f8240805fef33741e 100644 --- a/test/workers/repository/process/lookup/__snapshots__/index.spec.js.snap +++ b/test/workers/repository/process/lookup/__snapshots__/index.spec.js.snap @@ -109,6 +109,7 @@ Object { "updateType": "pin", }, ], + "warnings": Array [], } `; @@ -122,6 +123,7 @@ Object { "updateType": "pin", }, ], + "warnings": Array [], } `; @@ -157,6 +159,7 @@ Object { "updateType": "digest", }, ], + "warnings": Array [], } `; @@ -170,26 +173,13 @@ Object { "updateType": "digest", }, ], + "warnings": Array [], } `; -exports[`manager/npm/lookup .lookupUpdates() handles github 404 1`] = ` -Array [ - Object { - "message": "Failed to look up dependency foo", - "updateType": "warning", - }, -] -`; +exports[`manager/npm/lookup .lookupUpdates() handles github 404 1`] = `Array []`; -exports[`manager/npm/lookup .lookupUpdates() handles packagist 1`] = ` -Array [ - Object { - "message": "Failed to look up dependency foo/bar", - "updateType": "warning", - }, -] -`; +exports[`manager/npm/lookup .lookupUpdates() handles packagist 1`] = `Array []`; exports[`manager/npm/lookup .lookupUpdates() handles prerelease jumps 1`] = ` Array [ @@ -208,23 +198,9 @@ Array [ ] `; -exports[`manager/npm/lookup .lookupUpdates() handles pypi 404 1`] = ` -Array [ - Object { - "message": "Failed to look up dependency foo", - "updateType": "warning", - }, -] -`; +exports[`manager/npm/lookup .lookupUpdates() handles pypi 404 1`] = `Array []`; -exports[`manager/npm/lookup .lookupUpdates() handles unknown purl 1`] = ` -Array [ - Object { - "message": "Failed to look up dependency foo", - "updateType": "warning", - }, -] -`; +exports[`manager/npm/lookup .lookupUpdates() handles unknown purl 1`] = `Array []`; exports[`manager/npm/lookup .lookupUpdates() ignores deprecated 1`] = ` Object { @@ -261,6 +237,7 @@ Marking the latest version of an npm package as deprecated results in the entire "updateType": "minor", }, ], + "warnings": Array [], } `; @@ -427,6 +404,7 @@ Object { "updateType": "minor", }, ], + "warnings": Array [], } `; @@ -742,6 +720,7 @@ exports[`manager/npm/lookup .lookupUpdates() skips undefined values 1`] = ` Object { "skipReason": "unsupported-value", "updates": Array [], + "warnings": Array [], } `; @@ -749,6 +728,7 @@ exports[`manager/npm/lookup .lookupUpdates() skips unsupported values 1`] = ` Object { "skipReason": "unsupported-value", "updates": Array [], + "warnings": Array [], } `; diff --git a/test/workers/repository/updates/branchify.spec.js b/test/workers/repository/updates/branchify.spec.js index e75c7f14426266d485f18ff9a4c2b5f789326641..0c6bcf9fe16be67d1bc6f1fdf3c1b6efc4c14eb6 100644 --- a/test/workers/repository/updates/branchify.spec.js +++ b/test/workers/repository/updates/branchify.spec.js @@ -114,33 +114,6 @@ describe('workers/repository/updates/branchify', () => { const res = await branchifyUpgrades(config); expect(Object.keys(res.branches).length).toBe(2); }); - it('mixes errors and warnings', async () => { - flattenUpdates.mockReturnValueOnce([ - { - updateType: 'error', - }, - { - branchName: 'foo-{{version}}', - prTitle: 'some-title', - version: '1.1.0', - }, - { - updateType: 'warning', - branchName: 'foo-{{version}}', - prTitle: 'some-title', - version: '2.0.0', - }, - { - branchName: 'bar-{{version}}', - prTitle: 'some-title', - version: '1.1.0', - }, - ]); - const res = await branchifyUpgrades(config); - expect(Object.keys(res.branches).length).toBe(2); - expect(res.errors).toHaveLength(1); - expect(res.warnings).toHaveLength(1); - }); it('enforces valid git branch name', async () => { const fixtures = [ {