mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
fix(terraform): handle greater than with full version (#9632)
This commit is contained in:
parent
8b8d7767bc
commit
df2f451e37
2 changed files with 32 additions and 4 deletions
|
@ -67,6 +67,30 @@ describe('semver.getNewValue()', () => {
|
|||
newVersion: '2.0.7',
|
||||
})
|
||||
).toEqual('~> 2.0.0');
|
||||
expect(
|
||||
semver.getNewValue({
|
||||
currentValue: '~> 0.14.0',
|
||||
rangeStrategy: 'replace',
|
||||
currentVersion: '0.14.1',
|
||||
newVersion: '0.15.0',
|
||||
})
|
||||
).toEqual('~> 0.15.0');
|
||||
expect(
|
||||
semver.getNewValue({
|
||||
currentValue: '~> 0.14.0',
|
||||
rangeStrategy: 'replace',
|
||||
currentVersion: '0.14.1',
|
||||
newVersion: '0.15.1',
|
||||
})
|
||||
).toEqual('~> 0.15.0');
|
||||
expect(
|
||||
semver.getNewValue({
|
||||
currentValue: '~> 0.14.6',
|
||||
rangeStrategy: 'replace',
|
||||
currentVersion: '0.14.6',
|
||||
newVersion: '0.15.0',
|
||||
})
|
||||
).toEqual('~> 0.15.0');
|
||||
});
|
||||
it('handles comma dividers', () => {
|
||||
expect(
|
||||
|
|
|
@ -36,10 +36,14 @@ function getNewValue({
|
|||
newVersion,
|
||||
}: NewValueConfig): string {
|
||||
if (/~>\s*0\.\d+/.test(currentValue) && npm.getMajor(newVersion) === 0) {
|
||||
return currentValue.replace(
|
||||
/(~>\s*0\.).*$/,
|
||||
`$1${npm.getMinor(newVersion)}`
|
||||
);
|
||||
const testFullVersion = /(~>\s*0\.)(\d+)\.\d$/;
|
||||
let replaceValue = '';
|
||||
if (testFullVersion.test(currentValue)) {
|
||||
replaceValue = `$1${npm.getMinor(newVersion)}.0`;
|
||||
} else {
|
||||
replaceValue = `$1${npm.getMinor(newVersion)}$3`;
|
||||
}
|
||||
return currentValue.replace(/(~>\s*0\.)(\d+)(.*)$/, replaceValue);
|
||||
}
|
||||
// handle special ~> 1.2 case
|
||||
if (/(~>\s*)\d+\.\d+$/.test(currentValue)) {
|
||||
|
|
Loading…
Reference in a new issue