From 675e569daa712c6b75ab1a38ae899304a2b276c4 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek <tobias@bieniek.cloud> Date: Sun, 12 Feb 2023 07:33:03 +0100 Subject: [PATCH] fix(cargo): fix pinning for wildcard constraints (#20355) --- lib/modules/versioning/cargo/index.spec.ts | 10 ++++++++++ lib/modules/versioning/cargo/index.ts | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/modules/versioning/cargo/index.spec.ts b/lib/modules/versioning/cargo/index.spec.ts index d4e6c33ce1..beb92118f2 100644 --- a/lib/modules/versioning/cargo/index.spec.ts +++ b/lib/modules/versioning/cargo/index.spec.ts @@ -92,6 +92,16 @@ describe('modules/versioning/cargo/index', () => { test.each` currentValue | rangeStrategy | currentVersion | newVersion | expected + ${'*'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'} + ${'1'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'} + ${'1.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'} + ${'1.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'} + ${'^1'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'} + ${'^1.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'} + ${'^1.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'} + ${'~1'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'} + ${'~1.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'} + ${'~1.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'} ${null} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${null} ${'*'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'*'} ${'=1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'} diff --git a/lib/modules/versioning/cargo/index.ts b/lib/modules/versioning/cargo/index.ts index c18b1ea625..52562646f3 100644 --- a/lib/modules/versioning/cargo/index.ts +++ b/lib/modules/versioning/cargo/index.ts @@ -94,7 +94,7 @@ function getNewValue({ newVersion, }: NewValueConfig): string { if (!currentValue || currentValue === '*') { - return currentValue; + return rangeStrategy === 'pin' ? `=${newVersion}` : currentValue; } if (rangeStrategy === 'pin' || isSingleVersion(currentValue)) { let res = '='; -- GitLab