From 58fabd68e8e8a04ba36a8820d0e401ad1870b252 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Sun, 4 Apr 2021 11:05:55 +0200 Subject: [PATCH] feat: updateType=patch (#9393) Changes behavior so that patch updateType is not rewritten to minor by default. Closes #2818 BREAKING CHANGE: patch updates are not considered updateType=minor by default. --- docs/usage/configuration-options.md | 1 - docs/usage/faq.md | 5 +- lib/config/definitions.ts | 3 +- lib/config/presets/internal/group.ts | 12 ++ .../lookup/__snapshots__/index.spec.ts.snap | 110 +++++++++--------- .../repository/process/lookup/index.spec.ts | 8 +- .../repository/process/lookup/update-type.ts | 5 +- 7 files changed, 74 insertions(+), 70 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index cdc201c44d69c4..d7e7a8af0bb7e5 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -1517,7 +1517,6 @@ For example to apply a special label for Major updates: ## patch Add to this object if you wish to define rules that apply only to patch updates. -Only applies if `separateMinorPatch` is set to true. ## php diff --git a/docs/usage/faq.md b/docs/usage/faq.md index bcf253b27896bf..5c71756c2c5e31 100644 --- a/docs/usage/faq.md +++ b/docs/usage/faq.md @@ -208,10 +208,7 @@ To learn more read the section below. You can see in the example above that Renovate won't normally open a PR for the `snorgleborf` patch release. -There are 2 ways to tell Renovate to open a separate PR for the patch release: - -- Set `separateMinorPatch` to `true` -- Set `automerge` to the value: `"patch"` +You can tell Renovate to open a separate PR for the patch release by setting `separateMinorPatch` to `true`. In both cases, Renovate will open 3 PRs: diff --git a/lib/config/definitions.ts b/lib/config/definitions.ts index 25d9db12e36ff8..049bb00fa2b11b 100644 --- a/lib/config/definitions.ts +++ b/lib/config/definitions.ts @@ -1058,8 +1058,7 @@ const options: RenovateOptions[] = [ }, { name: 'patch', - description: - 'Configuration to apply when an update type is patch. Only applies if `separateMinorPatch` is set to true.', + description: 'Configuration to apply when an update type is patch.', stage: 'package', type: 'object', default: {}, diff --git a/lib/config/presets/internal/group.ts b/lib/config/presets/internal/group.ts index 3f9d21d16bb3fa..e4e75ef8898c6e 100644 --- a/lib/config/presets/internal/group.ts +++ b/lib/config/presets/internal/group.ts @@ -499,6 +499,9 @@ const staticGroups = { minor: { groupName: 'JS unit test packages', }, + patch: { + groupName: 'JS unit test packages', + }, }, ], }, @@ -519,6 +522,9 @@ const staticGroups = { minor: { groupName: 'unit test packages', }, + patch: { + groupName: 'unit test packages', + }, }, ], }, @@ -539,6 +545,9 @@ const staticGroups = { minor: { groupName: 'JS test packages', }, + patch: { + groupName: 'JS test packages', + }, }, ], }, @@ -559,6 +568,9 @@ const staticGroups = { minor: { groupName: 'test packages', }, + patch: { + groupName: 'test packages', + }, }, ], }, diff --git a/lib/workers/repository/process/lookup/__snapshots__/index.spec.ts.snap b/lib/workers/repository/process/lookup/__snapshots__/index.spec.ts.snap index 4949a7f74b6b64..cbd11fcf390893 100644 --- a/lib/workers/repository/process/lookup/__snapshots__/index.spec.ts.snap +++ b/lib/workers/repository/process/lookup/__snapshots__/index.spec.ts.snap @@ -112,7 +112,7 @@ Array [ "0.9.5", "0.9.6", ], - "updateType": "minor", + "updateType": "patch", }, Object { "blockedByPin": true, @@ -705,53 +705,7 @@ Array [ "0.9.5", "0.9.6", ], - "updateType": "minor", - }, - Object { - "bucket": "major", - "currentVersion": "0.9.0", - "isSingleVersion": true, - "newMajor": 1, - "newMinor": 4, - "newValue": "1.4.1", - "newVersion": "1.4.1", - "releaseTimestamp": "2015-05-17T04:25:07.299Z", - "skippedOverVersions": Array [ - "1.0.0", - "1.0.1", - "1.1.0", - "1.1.1", - "1.1.2", - "1.2.0", - "1.2.1", - "1.3.0", - "1.4.0", - ], - "updateType": "major", - }, -] -`; - -exports[`workers/repository/process/lookup .lookupUpdates() returns minor update if separate patches not configured 1`] = ` -Array [ - Object { - "bucket": "non-major", - "currentVersion": "0.9.0", - "isSingleVersion": true, - "newMajor": 0, - "newMinor": 9, - "newValue": "0.9.7", - "newVersion": "0.9.7", - "releaseTimestamp": "2013-09-04T17:07:22.948Z", - "skippedOverVersions": Array [ - "0.9.1", - "0.9.2", - "0.9.3", - "0.9.4", - "0.9.5", - "0.9.6", - ], - "updateType": "minor", + "updateType": "patch", }, Object { "bucket": "major", @@ -979,6 +933,52 @@ Array [ ] `; +exports[`workers/repository/process/lookup .lookupUpdates() returns patch update even if separate patches not configured 1`] = ` +Array [ + Object { + "bucket": "non-major", + "currentVersion": "0.9.0", + "isSingleVersion": true, + "newMajor": 0, + "newMinor": 9, + "newValue": "0.9.7", + "newVersion": "0.9.7", + "releaseTimestamp": "2013-09-04T17:07:22.948Z", + "skippedOverVersions": Array [ + "0.9.1", + "0.9.2", + "0.9.3", + "0.9.4", + "0.9.5", + "0.9.6", + ], + "updateType": "patch", + }, + Object { + "bucket": "major", + "currentVersion": "0.9.0", + "isSingleVersion": true, + "newMajor": 1, + "newMinor": 4, + "newValue": "1.4.1", + "newVersion": "1.4.1", + "releaseTimestamp": "2015-05-17T04:25:07.299Z", + "skippedOverVersions": Array [ + "1.0.0", + "1.0.1", + "1.1.0", + "1.1.1", + "1.1.2", + "1.2.0", + "1.2.1", + "1.3.0", + "1.4.0", + ], + "updateType": "major", + }, +] +`; + exports[`workers/repository/process/lookup .lookupUpdates() returns patch update if separateMinorPatch 1`] = ` Array [ Object { @@ -1096,7 +1096,7 @@ Array [ "3.1.0-dev.20180809", "3.1.0-dev.20180810", ], - "updateType": "minor", + "updateType": "patch", }, ] `; @@ -1112,7 +1112,7 @@ Array [ "newValue": "2.5.17-beta.0", "newVersion": "2.5.17-beta.0", "releaseTimestamp": "2018-03-23T23:29:13.819Z", - "updateType": "minor", + "updateType": "patch", }, ] `; @@ -1140,7 +1140,7 @@ Array [ "newValue": "3.0.1-insiders.20180726", "newVersion": "3.0.1-insiders.20180726", "releaseTimestamp": "2018-07-26T18:20:51.679Z", - "updateType": "minor", + "updateType": "patch", }, ] `; @@ -1171,7 +1171,7 @@ Array [ "newValue": "3.0.1-insiders.20180726", "newVersion": "3.0.1-insiders.20180726", "releaseTimestamp": "2018-07-26T18:20:51.679Z", - "updateType": "minor", + "updateType": "patch", }, ] `; @@ -1187,7 +1187,7 @@ Array [ "newValue": "3.0.1", "newVersion": "3.0.1", "releaseTimestamp": "2018-07-30T16:21:13.150Z", - "updateType": "minor", + "updateType": "patch", }, ] `; @@ -1218,7 +1218,7 @@ Array [ "newValue": "^0.0.35", "newVersion": "0.0.35", "releaseTimestamp": "2017-04-27T16:59:06.479Z", - "updateType": "minor", + "updateType": "patch", }, ] `; @@ -2648,7 +2648,7 @@ Array [ "newValue": "1.0.1", "newVersion": "1.0.1", "releaseTimestamp": "2014-03-11T18:47:17.560Z", - "updateType": "minor", + "updateType": "patch", }, ] `; diff --git a/lib/workers/repository/process/lookup/index.spec.ts b/lib/workers/repository/process/lookup/index.spec.ts index fbee93dd5f69f8..59ad3eb91dd16e 100644 --- a/lib/workers/repository/process/lookup/index.spec.ts +++ b/lib/workers/repository/process/lookup/index.spec.ts @@ -186,7 +186,7 @@ describe('workers/repository/process/lookup', () => { Error(CONFIG_VALIDATION) ); }); - it('returns minor update if separate patches not configured', async () => { + it('returns patch update even if separate patches not configured', async () => { config.currentValue = '0.9.0'; config.rangeStrategy = 'pin'; config.depName = 'q'; @@ -195,8 +195,8 @@ describe('workers/repository/process/lookup', () => { const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); expect(res.updates).toHaveLength(2); - expect(res.updates[0].updateType).not.toEqual('patch'); - expect(res.updates[1].updateType).not.toEqual('patch'); + expect(res.updates[0].updateType).toEqual('patch'); + expect(res.updates[1].updateType).toEqual('major'); }); it('returns minor update if automerging both patch and minor', async () => { config.patch = { @@ -212,7 +212,7 @@ describe('workers/repository/process/lookup', () => { nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); - expect(res.updates[0].updateType).toEqual('minor'); + expect(res.updates[0].updateType).toEqual('patch'); }); it('returns patch update if separateMinorPatch', async () => { config.separateMinorPatch = true; diff --git a/lib/workers/repository/process/lookup/update-type.ts b/lib/workers/repository/process/lookup/update-type.ts index 2ec97d4dba5011..028931a23d32ae 100644 --- a/lib/workers/repository/process/lookup/update-type.ts +++ b/lib/workers/repository/process/lookup/update-type.ts @@ -19,8 +19,5 @@ export function getUpdateType( if (versioning.getMinor(newVersion) > versioning.getMinor(currentVersion)) { return 'minor'; } - if (config.separateMinorPatch) { - return 'patch'; - } - return 'minor'; + return 'patch'; }