mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
fix: do not jump unstable versions implicitly
If the current value is already unstable then we presume the user is happy to take newer unstable versions. However we should not presume that they want to keep jumping versions if so and instead would prefer to stabilise. Discussed in #2258 but does not close it
This commit is contained in:
parent
d376f9db87
commit
d2885e5d9e
4 changed files with 54 additions and 45 deletions
|
@ -18,9 +18,15 @@ function filterVersions(
|
||||||
respectLatest,
|
respectLatest,
|
||||||
allowedVersions,
|
allowedVersions,
|
||||||
} = config;
|
} = config;
|
||||||
const { getMajor, isGreaterThan, isStable, isValid, matches } = versioning(
|
const {
|
||||||
versionScheme
|
getMajor,
|
||||||
);
|
getMinor,
|
||||||
|
getPatch,
|
||||||
|
isGreaterThan,
|
||||||
|
isStable,
|
||||||
|
isValid,
|
||||||
|
matches,
|
||||||
|
} = versioning(versionScheme);
|
||||||
if (!fromVersion) {
|
if (!fromVersion) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -67,7 +73,10 @@ function filterVersions(
|
||||||
// Allow unstable only in current major
|
// Allow unstable only in current major
|
||||||
return filteredVersions.filter(
|
return filteredVersions.filter(
|
||||||
version =>
|
version =>
|
||||||
isStable(version) || getMajor(version) === getMajor(fromVersion)
|
isStable(version) ||
|
||||||
|
(getMajor(version) === getMajor(fromVersion) &&
|
||||||
|
getMinor(version) === getMinor(fromVersion) &&
|
||||||
|
getPatch(version) === getPatch(fromVersion))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -201,23 +201,6 @@ exports[`manager/npm/lookup .lookupUpdates() handles github 404 1`] = `Array []`
|
||||||
|
|
||||||
exports[`manager/npm/lookup .lookupUpdates() handles packagist 1`] = `Array []`;
|
exports[`manager/npm/lookup .lookupUpdates() handles packagist 1`] = `Array []`;
|
||||||
|
|
||||||
exports[`manager/npm/lookup .lookupUpdates() handles prerelease jumps 1`] = `
|
|
||||||
Array [
|
|
||||||
Object {
|
|
||||||
"canBeUnpublished": false,
|
|
||||||
"fromVersion": "2.9.0-rc",
|
|
||||||
"isRange": true,
|
|
||||||
"isSingleVersion": false,
|
|
||||||
"newMajor": 2,
|
|
||||||
"newMinor": 9,
|
|
||||||
"newValue": "^2.9.1-insiders",
|
|
||||||
"releaseTimestamp": "2018-05-16T23:16:36.911Z",
|
|
||||||
"toVersion": "2.9.1-insiders.20180516",
|
|
||||||
"updateType": "minor",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`manager/npm/lookup .lookupUpdates() handles pypi 404 1`] = `Array []`;
|
exports[`manager/npm/lookup .lookupUpdates() handles pypi 404 1`] = `Array []`;
|
||||||
|
|
||||||
exports[`manager/npm/lookup .lookupUpdates() handles unknown purl 1`] = `Array []`;
|
exports[`manager/npm/lookup .lookupUpdates() handles unknown purl 1`] = `Array []`;
|
||||||
|
@ -679,13 +662,13 @@ exports[`manager/npm/lookup .lookupUpdates() should allow unstable versions if t
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
"canBeUnpublished": false,
|
"canBeUnpublished": false,
|
||||||
"fromVersion": "2.3.0-beta.1",
|
"fromVersion": "3.1.0-dev.20180731",
|
||||||
"isSingleVersion": true,
|
"isSingleVersion": true,
|
||||||
"newMajor": 2,
|
"newMajor": 3,
|
||||||
"newMinor": 5,
|
"newMinor": 1,
|
||||||
"newValue": "2.5.17-beta.0",
|
"newValue": "3.1.0-dev.20180813",
|
||||||
"releaseTimestamp": "2018-03-23T23:29:13.819Z",
|
"releaseTimestamp": "2018-08-13T19:05:14.347Z",
|
||||||
"toVersion": "2.5.17-beta.0",
|
"toVersion": "3.1.0-dev.20180813",
|
||||||
"updateType": "minor",
|
"updateType": "minor",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -719,6 +702,22 @@ Object {
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`manager/npm/lookup .lookupUpdates() should not jump unstable versions 1`] = `
|
||||||
|
Array [
|
||||||
|
Object {
|
||||||
|
"canBeUnpublished": false,
|
||||||
|
"fromVersion": "3.0.1-insiders.20180726",
|
||||||
|
"isSingleVersion": true,
|
||||||
|
"newMajor": 3,
|
||||||
|
"newMinor": 0,
|
||||||
|
"newValue": "3.0.1",
|
||||||
|
"releaseTimestamp": "2018-07-30T16:21:13.150Z",
|
||||||
|
"toVersion": "3.0.1",
|
||||||
|
"updateType": "minor",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`manager/npm/lookup .lookupUpdates() should treat zero zero caret ranges as pinned 1`] = `
|
exports[`manager/npm/lookup .lookupUpdates() should treat zero zero caret ranges as pinned 1`] = `
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
|
|
|
@ -641,16 +641,28 @@ describe('manager/npm/lookup', () => {
|
||||||
expect(res.updates[0].newValue).toEqual('2.5.17-beta.0');
|
expect(res.updates[0].newValue).toEqual('2.5.17-beta.0');
|
||||||
});
|
});
|
||||||
it('should allow unstable versions if the current version is unstable', async () => {
|
it('should allow unstable versions if the current version is unstable', async () => {
|
||||||
config.currentValue = '2.3.0-beta.1';
|
config.currentValue = '3.1.0-dev.20180731';
|
||||||
config.depName = 'vue';
|
config.depName = 'typescript';
|
||||||
config.purl = 'pkg:npm/vue';
|
config.purl = 'pkg:npm/typescript';
|
||||||
nock('https://registry.npmjs.org')
|
nock('https://registry.npmjs.org')
|
||||||
.get('/vue')
|
.get('/typescript')
|
||||||
.reply(200, vueJson);
|
.reply(200, typescriptJson);
|
||||||
const res = await lookup.lookupUpdates(config);
|
const res = await lookup.lookupUpdates(config);
|
||||||
expect(res.updates).toMatchSnapshot();
|
expect(res.updates).toMatchSnapshot();
|
||||||
expect(res.updates).toHaveLength(1);
|
expect(res.updates).toHaveLength(1);
|
||||||
expect(res.updates[0].newValue).toEqual('2.5.17-beta.0');
|
expect(res.updates[0].newValue).toEqual('3.1.0-dev.20180813');
|
||||||
|
});
|
||||||
|
it('should not jump unstable versions', async () => {
|
||||||
|
config.currentValue = '3.0.1-insiders.20180726';
|
||||||
|
config.depName = 'typescript';
|
||||||
|
config.purl = 'pkg:npm/typescript';
|
||||||
|
nock('https://registry.npmjs.org')
|
||||||
|
.get('/typescript')
|
||||||
|
.reply(200, typescriptJson);
|
||||||
|
const res = await lookup.lookupUpdates(config);
|
||||||
|
expect(res.updates).toMatchSnapshot();
|
||||||
|
expect(res.updates).toHaveLength(1);
|
||||||
|
expect(res.updates[0].newValue).toEqual('3.0.1');
|
||||||
});
|
});
|
||||||
it('should treat zero zero tilde ranges as 0.0.x', async () => {
|
it('should treat zero zero tilde ranges as 0.0.x', async () => {
|
||||||
config.rangeStrategy = 'replace';
|
config.rangeStrategy = 'replace';
|
||||||
|
@ -715,17 +727,6 @@ describe('manager/npm/lookup', () => {
|
||||||
const res = await lookup.lookupUpdates(config);
|
const res = await lookup.lookupUpdates(config);
|
||||||
expect(res.updates).toHaveLength(0);
|
expect(res.updates).toHaveLength(0);
|
||||||
});
|
});
|
||||||
it('handles prerelease jumps', async () => {
|
|
||||||
config.currentValue = '^2.9.0-rc';
|
|
||||||
config.rangeStrategy = 'replace';
|
|
||||||
config.depName = 'typescript';
|
|
||||||
config.purl = 'pkg:npm/typescript';
|
|
||||||
nock('https://registry.npmjs.org')
|
|
||||||
.get('/typescript')
|
|
||||||
.reply(200, typescriptJson);
|
|
||||||
const res = await lookup.lookupUpdates(config);
|
|
||||||
expect(res.updates).toMatchSnapshot();
|
|
||||||
});
|
|
||||||
it('supports in-range caret updates', async () => {
|
it('supports in-range caret updates', async () => {
|
||||||
config.rangeStrategy = 'bump';
|
config.rangeStrategy = 'bump';
|
||||||
config.currentValue = '^1.0.0';
|
config.currentValue = '^1.0.0';
|
||||||
|
|
Loading…
Reference in a new issue