mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 14:36:25 +00:00
fix(ruby): match precision for new ranges (#5035)
This commit is contained in:
parent
7e9db42ce0
commit
118a3452e2
2 changed files with 13 additions and 4 deletions
|
@ -9,7 +9,15 @@ export default ({ to, range }: { range: string; to: string }): string => {
|
||||||
.split(',')
|
.split(',')
|
||||||
.map(part => part.trim())
|
.map(part => part.trim())
|
||||||
.pop();
|
.pop();
|
||||||
const newLastPart = bump({ to, range: lastPart });
|
const lastPartPrecision = lastPart.split('.').length;
|
||||||
// TODO: match precision
|
const toPrecision = to.split('.').length;
|
||||||
|
let massagedTo: string = to;
|
||||||
|
if (!lastPart.startsWith('<') && toPrecision > lastPartPrecision) {
|
||||||
|
massagedTo = to
|
||||||
|
.split('.')
|
||||||
|
.slice(0, lastPartPrecision)
|
||||||
|
.join('.');
|
||||||
|
}
|
||||||
|
const newLastPart = bump({ to: massagedTo, range: lastPart });
|
||||||
return range.replace(lastPart, newLastPart);
|
return range.replace(lastPart, newLastPart);
|
||||||
};
|
};
|
||||||
|
|
|
@ -423,12 +423,13 @@ describe('semverRuby', () => {
|
||||||
['~> 1.0.3', '~> 1.0.3', 'replace', '1.0.0', '1.0.4'],
|
['~> 1.0.3', '~> 1.0.3', 'replace', '1.0.0', '1.0.4'],
|
||||||
['~> 4.7, >= 4.7.4', '~> 4.7, >= 4.7.4', 'replace', '1.0.0', '4.7.9'],
|
['~> 4.7, >= 4.7.4', '~> 4.7, >= 4.7.4', 'replace', '1.0.0', '4.7.9'],
|
||||||
[
|
[
|
||||||
'>= 2.0.0, <= 2.20.0',
|
'>= 2.0.0, <= 2.20.1',
|
||||||
'>= 2.0.0, <= 2.15',
|
'>= 2.0.0, <= 2.15',
|
||||||
'replace',
|
'replace',
|
||||||
'2.15.0',
|
'2.15.0',
|
||||||
'2.20.0',
|
'2.20.1',
|
||||||
],
|
],
|
||||||
|
['~> 6.0.0', '~> 5.2.0', 'replace', '5.2.4.1', '6.0.2.1'],
|
||||||
].forEach(([expected, current, range, from, to]) => {
|
].forEach(([expected, current, range, from, to]) => {
|
||||||
expect(semverRuby.getNewValue(current, range as any, from, to)).toEqual(
|
expect(semverRuby.getNewValue(current, range as any, from, to)).toEqual(
|
||||||
expected
|
expected
|
||||||
|
|
Loading…
Reference in a new issue