Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(versioning)!: bump short ranges to version #20494

Merged
merged 12 commits into from
Feb 20, 2023
Merged
6 changes: 3 additions & 3 deletions lib/modules/versioning/cargo/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ describe('modules/versioning/cargo/index', () => {
${' = 1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'}
${'= 1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'= 1.1.0'}
${'1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'1.1.0'}
${'^1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.0.7'} | ${'^1.0'}
${'^1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.0.7'} | ${'^1.0.7'}
${'^1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'2.0.7'} | ${'^2.0.0'}
${'1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'2.0.7'} | ${'2.0.0'}
${'^1'} | ${'bump'} | ${'1.0.0'} | ${'2.1.7'} | ${'^2'}
${'~1'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'~1'}
${'^1'} | ${'bump'} | ${'1.0.0'} | ${'2.1.7'} | ${'^2.1.7'}
${'~1'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'~1.1.7'}
${'5'} | ${'bump'} | ${'5.0.0'} | ${'5.1.7'} | ${'5'}
${'5'} | ${'bump'} | ${'5.0.0'} | ${'6.1.7'} | ${'6'}
${'5.0'} | ${'bump'} | ${'5.0.0'} | ${'5.0.7'} | ${'5.0'}
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/versioning/composer/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('modules/versioning/composer/index', () => {
${'~1.0 || >=3.0 <=4.0'} | ${'widen'} | ${'2.9.0'} | ${'5.0.0'} | ${'~1.0 || >=3.0 <=5.0'}
${'+4.0.0'} | ${'replace'} | ${'4.0.0'} | ${'4.2.0'} | ${'4.2.0'}
${'v4.0.0'} | ${'replace'} | ${'4.0.0'} | ${'4.2.0'} | ${'v4.2.0'}
${'^v1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'^v1.1'}
${'^v1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'^v1.1.7'}
${'^v1.0@beta'} | ${'bump'} | ${'1.0.0-beta3'} | ${'1.0.0-beta5'} | ${'^v1.0.0-beta5@beta'}
${'^v1.0@beta'} | ${'replace'} | ${'1.0.0-beta3'} | ${'2.0.0-beta5'} | ${'^v2.0.0-beta5@beta'}
${'^4.0@alpha'} | ${'replace'} | ${'4.0.0-alpha1'} | ${'4.0.0-beta5'} | ${'^4.0.0-beta5@alpha'}
Expand Down
10 changes: 5 additions & 5 deletions lib/modules/versioning/helm/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ describe('modules/versioning/helm/index', () => {
test.each`
currentValue | rangeStrategy | currentVersion | newVersion | expected
${'=1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'}
${'^1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.0.7'} | ${'^1.0'}
${'^1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.0.7'} | ${'^1.0.7'}
${'^1'} | ${'bump'} | ${'1.0.0'} | ${'1.0.7-prerelease.1'} | ${'^1.0.7-prerelease.1'}
${'^1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'^1.1'}
${'~1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'~1.1'}
${'^1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'^1.1.7'}
${'~1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'~1.1.7'}
${'~1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.0.7-prerelease.1'} | ${'~1.0.7-prerelease.1'}
${'^1'} | ${'bump'} | ${'1.0.0'} | ${'2.1.7'} | ${'^2'}
${'~1'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'~1'}
${'^1'} | ${'bump'} | ${'1.0.0'} | ${'2.1.7'} | ${'^2.1.7'}
${'~1'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'~1.1.7'}
${'5'} | ${'bump'} | ${'5.0.0'} | ${'5.1.7'} | ${'5'}
${'5'} | ${'bump'} | ${'5.0.0'} | ${'6.1.7'} | ${'6'}
${'5.0'} | ${'bump'} | ${'5.0.0'} | ${'5.0.7'} | ${'5.0'}
Expand Down
10 changes: 5 additions & 5 deletions lib/modules/versioning/npm/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ describe('modules/versioning/npm/index', () => {
test.each`
currentValue | rangeStrategy | currentVersion | newVersion | expected
${'=1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'}
${'^1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.0.7'} | ${'^1.0'}
${'^1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.0.7'} | ${'^1.0.7'}
${'^1'} | ${'bump'} | ${'1.0.0'} | ${'1.0.7-prerelease.1'} | ${'^1.0.7-prerelease.1'}
${'~> 1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'1.1.7'} | ${'~> 1.1.0'}
${'^1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'^1.1'}
${'~1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'~1.1'}
${'^1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'^1.1.7'}
${'~1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'~1.1.7'}
${'~1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.0.7-prerelease.1'} | ${'~1.0.7-prerelease.1'}
${'^1'} | ${'bump'} | ${'1.0.0'} | ${'2.1.7'} | ${'^2'}
${'~1'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'~1'}
${'^1'} | ${'bump'} | ${'1.0.0'} | ${'2.1.7'} | ${'^2.1.7'}
${'~1'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'~1.1.7'}
${'5'} | ${'bump'} | ${'5.0.0'} | ${'5.1.7'} | ${'5'}
${'5'} | ${'bump'} | ${'5.0.0'} | ${'6.1.7'} | ${'6'}
${'5.0'} | ${'bump'} | ${'5.0.0'} | ${'5.0.7'} | ${'5.0'}
Expand Down
24 changes: 0 additions & 24 deletions lib/modules/versioning/npm/range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,33 +136,9 @@ export function getNewValue({
});
}
if (element.operator === '^') {
const split = currentValue.split('.');
if (suffix.length) {
return `^${newVersion}`;
}
if (split.length === 1) {
// ^4
return `^${toVersionMajor}`;
}
if (split.length === 2) {
// ^4.1
return `^${toVersionMajor}.${toVersionMinor}`;
}
return `^${newVersion}`;
}
if (element.operator === '~') {
const split = currentValue.split('.');
if (suffix.length) {
return `~${newVersion}`;
}
if (split.length === 1) {
// ~4
return `~${toVersionMajor}`;
}
if (split.length === 2) {
// ~4.1
return `~${toVersionMajor}.${toVersionMinor}`;
}
return `~${newVersion}`;
}
if (element.operator === '=') {
Expand Down
8 changes: 4 additions & 4 deletions lib/modules/versioning/poetry/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ describe('modules/versioning/poetry/index', () => {
${' = 1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'}
${' = 1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'}
${'= 1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'}
${'^1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.0.7'} | ${'^1.0'}
${'^1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.0.7'} | ${'^1.0.7'}
${'^1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'2.0.7'} | ${'^2.0.0'}
${'^5.0.3'} | ${'replace'} | ${'5.3.1'} | ${'5.5'} | ${'^5.0.3'}
${'1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'2.0.7'} | ${'2.0.7'}
${'^1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'2.0.7'} | ${'^2.0.0'}
${'^0.5.15'} | ${'replace'} | ${'0.5.15'} | ${'0.6'} | ${'^0.5.15'}
${'^0.5.15'} | ${'replace'} | ${'0.5.15'} | ${'0.6b.4'} | ${'^0.5.15'}
${'^1'} | ${'bump'} | ${'1.0.0'} | ${'2.1.7'} | ${'^2'}
${'~1'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'~1'}
${'^1'} | ${'bump'} | ${'1.0.0'} | ${'2.1.7'} | ${'^2.1.7'}
${'~1'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'~1.1.7'}
${'5'} | ${'bump'} | ${'5.0.0'} | ${'5.1.7'} | ${'5'}
${'5'} | ${'bump'} | ${'5.0.0'} | ${'6.1.7'} | ${'6'}
${'5.0'} | ${'bump'} | ${'5.0.0'} | ${'5.0.7'} | ${'5.0'}
Expand All @@ -211,7 +211,7 @@ describe('modules/versioning/poetry/index', () => {
${'^0.8.0-alpha.0'} | ${'bump'} | ${'0.8.0-alpha.0'} | ${'0.8.0-alpha.1'} | ${'^0.8.0-alpha.1'}
${'^0.8.0-alpha.0'} | ${'bump'} | ${'0.8.0-alpha.0'} | ${'0.8.0a1'} | ${'^0.8.0-alpha.1'}
${'^1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'^1.0.0'}
${'~1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'~1.1'}
${'~1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'~1.1.7'}
${'1.0.*'} | ${'replace'} | ${'1.0.0'} | ${'1.1.0'} | ${'1.1.*'}
${'1.*'} | ${'replace'} | ${'1.0.0'} | ${'2.1.0'} | ${'2.*'}
${'~0.6.1'} | ${'replace'} | ${'0.6.8'} | ${'0.7.0-rc.2'} | ${'~0.7.0-rc'}
Expand Down