mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
fix(cargo): handle * getNewValue
This commit is contained in:
parent
2bc36adcdb
commit
6bb76c53b6
2 changed files with 34 additions and 0 deletions
|
@ -103,6 +103,24 @@ describe('semver.isSingleVersion()', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('semver.getNewValue()', () => {
|
describe('semver.getNewValue()', () => {
|
||||||
|
it('returns if empty or *', () => {
|
||||||
|
expect(
|
||||||
|
semver.getNewValue({
|
||||||
|
currentValue: null,
|
||||||
|
rangeStrategy: 'bump',
|
||||||
|
fromVersion: '1.0.0',
|
||||||
|
toVersion: '1.1.0',
|
||||||
|
})
|
||||||
|
).toEqual(null);
|
||||||
|
expect(
|
||||||
|
semver.getNewValue({
|
||||||
|
currentValue: '*',
|
||||||
|
rangeStrategy: 'bump',
|
||||||
|
fromVersion: '1.0.0',
|
||||||
|
toVersion: '1.1.0',
|
||||||
|
})
|
||||||
|
).toEqual('*');
|
||||||
|
});
|
||||||
it('bumps equals', () => {
|
it('bumps equals', () => {
|
||||||
expect(
|
expect(
|
||||||
semver.getNewValue({
|
semver.getNewValue({
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { api as npm } from '../npm';
|
import { api as npm } from '../npm';
|
||||||
import { VersioningApi, NewValueConfig } from '../common';
|
import { VersioningApi, NewValueConfig } from '../common';
|
||||||
|
import { logger } from '../../logger';
|
||||||
|
|
||||||
export const id = 'cargo';
|
export const id = 'cargo';
|
||||||
export const displayName = 'Cargo';
|
export const displayName = 'Cargo';
|
||||||
|
@ -33,6 +34,10 @@ function notEmpty(s: string): boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
function npm2cargo(input: string): string {
|
function npm2cargo(input: string): string {
|
||||||
|
// istanbul ignore if
|
||||||
|
if (!input) {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
// Note: this doesn't remove the ^
|
// Note: this doesn't remove the ^
|
||||||
const res = input
|
const res = input
|
||||||
.split(' ')
|
.split(' ')
|
||||||
|
@ -73,6 +78,9 @@ function getNewValue({
|
||||||
fromVersion,
|
fromVersion,
|
||||||
toVersion,
|
toVersion,
|
||||||
}: NewValueConfig): string {
|
}: NewValueConfig): string {
|
||||||
|
if (!currentValue || currentValue === '*') {
|
||||||
|
return currentValue;
|
||||||
|
}
|
||||||
if (rangeStrategy === 'pin' || isSingleVersion(currentValue)) {
|
if (rangeStrategy === 'pin' || isSingleVersion(currentValue)) {
|
||||||
let res = '=';
|
let res = '=';
|
||||||
if (currentValue.startsWith('= ')) {
|
if (currentValue.startsWith('= ')) {
|
||||||
|
@ -88,6 +96,14 @@ function getNewValue({
|
||||||
toVersion,
|
toVersion,
|
||||||
});
|
});
|
||||||
let newCargo = npm2cargo(newSemver);
|
let newCargo = npm2cargo(newSemver);
|
||||||
|
// istanbul ignore if
|
||||||
|
if (!newCargo) {
|
||||||
|
logger.info(
|
||||||
|
{ currentValue, newSemver },
|
||||||
|
'Could not get cargo version from semver'
|
||||||
|
);
|
||||||
|
return currentValue;
|
||||||
|
}
|
||||||
// Try to reverse any caret we added
|
// Try to reverse any caret we added
|
||||||
if (newCargo.startsWith('^') && !currentValue.startsWith('^')) {
|
if (newCargo.startsWith('^') && !currentValue.startsWith('^')) {
|
||||||
newCargo = newCargo.substring(1);
|
newCargo = newCargo.substring(1);
|
||||||
|
|
Loading…
Reference in a new issue