diff --git a/lib/modules/versioning/cargo/index.spec.ts b/lib/modules/versioning/cargo/index.spec.ts index 8198b12f40559296af64915f43a51d94f26a84b6..0c5e6a5ae52a5f734fbce5cc6267d13dbb5aee75 100644 --- a/lib/modules/versioning/cargo/index.spec.ts +++ b/lib/modules/versioning/cargo/index.spec.ts @@ -132,6 +132,7 @@ describe('modules/versioning/cargo/index', () => { ${'5.0'} | ${'bump'} | ${'5.0.0'} | ${'6.1.7'} | ${'6.1.7'} ${'0.5'} | ${'bump'} | ${'0.5.0'} | ${'0.5.1'} | ${'0.5.1'} ${'0.5'} | ${'bump'} | ${'0.5.0'} | ${'0.6.1'} | ${'0.6.1'} + ${'1.2'} | ${'replace'} | ${'1.2.3'} | ${'1.3.0'} | ${'1.2'} ${'5.0'} | ${'replace'} | ${'5.0.0'} | ${'5.1.7'} | ${'5.0'} ${'5.0'} | ${'replace'} | ${'5.0.0'} | ${'6.1.7'} | ${'6.0'} ${'0.5'} | ${'replace'} | ${'0.5.0'} | ${'0.6.1'} | ${'0.6'} diff --git a/lib/modules/versioning/cargo/index.ts b/lib/modules/versioning/cargo/index.ts index c78fc095cecfcbb55f18d6162d11f55670b93bf4..e8309f06a6826c27bf8987f615d4b347ac03edbf 100644 --- a/lib/modules/versioning/cargo/index.ts +++ b/lib/modules/versioning/cargo/index.ts @@ -106,6 +106,9 @@ function getNewValue({ res += newVersion; return res; } + if (rangeStrategy === 'replace' && matches(newVersion, currentValue)) { + return currentValue; + } const newSemver = npm.getNewValue({ currentValue: cargo2npm(currentValue), rangeStrategy, @@ -142,6 +145,7 @@ function getNewValue({ const components = currentValue.split('.').length; newCargo = withoutCaret.split('.').slice(0, components).join('.'); } + return newCargo; }