Skip to content

Commit

Permalink
fix(cargo): fix pinning for wildcard constraints (#20355)
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Feb 12, 2023
1 parent 9b78277 commit 675e569
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/modules/versioning/cargo/index.spec.ts
Expand Up @@ -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'}
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/versioning/cargo/index.ts
Expand Up @@ -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 = '=';
Expand Down

0 comments on commit 675e569

Please sign in to comment.