Skip to content

Commit f022ae3

Browse files
fix(cargo): preserve version metadata
1 parent 09a80b2 commit f022ae3

File tree

4 files changed

+62
-56
lines changed

4 files changed

+62
-56
lines changed

lib/modules/datasource/crate/__snapshots__/index.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ exports[`modules/datasource/crate/index > getReleases > processes real data: lib
299299
"version": "0.2.50",
300300
},
301301
{
302-
"version": "0.2.51",
302+
"version": "0.2.51+metadata",
303303
},
304304
],
305305
"sourceUrl": "https://github.com/rust-lang/libc",

lib/modules/datasource/crate/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class CrateDatasource extends Datasource {
110110
result.releases = lines
111111
.map((version) => {
112112
const release: Release = {
113-
version: version.vers.replace(/\+.*$/, ''),
113+
version: version.vers,
114114
};
115115
if (version.yanked) {
116116
release.isDeprecated = true;

lib/modules/versioning/cargo/index.spec.ts

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -99,59 +99,62 @@ describe('modules/versioning/cargo/index', () => {
9999
});
100100

101101
it.each`
102-
currentValue | rangeStrategy | currentVersion | newVersion | expected
103-
${'*'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
104-
${'1'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
105-
${'1.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
106-
${'1.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
107-
${'^1'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
108-
${'^1.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
109-
${'^1.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
110-
${'~1'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
111-
${'~0.7'} | ${'replace'} | ${'0.7.3'} | ${'0.8.5'} | ${'~0.8'}
112-
${'~1.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
113-
${'~1.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
114-
${null} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${null}
115-
${'*'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'*'}
116-
${'=1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'}
117-
${' =1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'}
118-
${'= 1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'= 1.1.0'}
119-
${' = 1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'}
120-
${' = 1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'}
121-
${'= 1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'= 1.1.0'}
122-
${'1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'1.1.0'}
123-
${'^1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.0.7'} | ${'^1.0.7'}
124-
${'^1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'2.0.7'} | ${'^2.0.0'}
125-
${'1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'2.0.7'} | ${'2.0.0'}
126-
${'^1'} | ${'bump'} | ${'1.0.0'} | ${'2.1.7'} | ${'^2.1.7'}
127-
${'~1'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'~1.1.7'}
128-
${'5'} | ${'bump'} | ${'5.0.0'} | ${'5.1.7'} | ${'5.1.7'}
129-
${'5'} | ${'bump'} | ${'5.0.0'} | ${'6.1.7'} | ${'6.1.7'}
130-
${'5.0'} | ${'bump'} | ${'5.0.0'} | ${'5.0.7'} | ${'5.0.7'}
131-
${'5.0'} | ${'bump'} | ${'5.0.0'} | ${'5.1.7'} | ${'5.1.7'}
132-
${'5.0'} | ${'bump'} | ${'5.0.0'} | ${'6.1.7'} | ${'6.1.7'}
133-
${'0.5'} | ${'bump'} | ${'0.5.0'} | ${'0.5.1'} | ${'0.5.1'}
134-
${'0.5'} | ${'bump'} | ${'0.5.0'} | ${'0.6.1'} | ${'0.6.1'}
135-
${'1.2'} | ${'replace'} | ${'1.2.3'} | ${'1.3.0'} | ${'1.2'}
136-
${'5.0'} | ${'replace'} | ${'5.0.0'} | ${'5.1.7'} | ${'5.0'}
137-
${'5.0'} | ${'replace'} | ${'5.0.0'} | ${'6.1.7'} | ${'6.0'}
138-
${'0.5'} | ${'replace'} | ${'0.5.0'} | ${'0.6.1'} | ${'0.6'}
139-
${'=1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'}
140-
${'1.0.*'} | ${'replace'} | ${'1.0.0'} | ${'1.1.0'} | ${'1.1.*'}
141-
${'1.*'} | ${'replace'} | ${'1.0.0'} | ${'2.1.0'} | ${'2.*'}
142-
${'~0.6.1'} | ${'replace'} | ${'0.6.8'} | ${'0.7.0-rc.2'} | ${'~0.7.0-rc'}
143-
${'<1.3.4'} | ${'replace'} | ${'1.2.3'} | ${'1.5.0'} | ${'<1.5.1'}
144-
${'< 1.3.4'} | ${'replace'} | ${'1.2.3'} | ${'1.5.0'} | ${'< 1.5.1'}
145-
${'< 1.3.4'} | ${'replace'} | ${'1.2.3'} | ${'1.5.0'} | ${'< 1.5.1'}
146-
${'<=1.3.4'} | ${'replace'} | ${'1.2.3'} | ${'1.5.0'} | ${'<=1.5.0'}
147-
${'<= 1.3.4'} | ${'replace'} | ${'1.2.3'} | ${'1.5.0'} | ${'<= 1.5.0'}
148-
${'<= 1.3.4'} | ${'replace'} | ${'1.2.3'} | ${'1.5.0'} | ${'<= 1.5.0'}
149-
${'>= 0.1.21, < 0.2.0'} | ${'bump'} | ${'0.1.21'} | ${'0.1.24'} | ${'>= 0.1.24, < 0.2.0'}
150-
${'>= 0.1.21, <= 0.2.0'} | ${'bump'} | ${'0.1.21'} | ${'0.1.24'} | ${'>= 0.1.24, <= 0.2.0'}
151-
${'>= 0.0.1, <= 0.1'} | ${'bump'} | ${'0.0.1'} | ${'0.0.2'} | ${'>= 0.0.2, <= 0.1'}
152-
${'>= 1.2.3, <= 1'} | ${'bump'} | ${'1.2.3'} | ${'1.2.4'} | ${'>= 1.2.4, <= 1'}
153-
${'>= 1.2.3, <= 1.0'} | ${'bump'} | ${'1.2.3'} | ${'1.2.4'} | ${'>= 1.2.4, <= 1.2'}
154-
${'>= 0.0.1, < 0.1'} | ${'bump'} | ${'0.1.0'} | ${'0.2.1'} | ${'>= 0.2.1, < 0.3'}
102+
currentValue | rangeStrategy | currentVersion | newVersion | expected
103+
${'*'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
104+
${'1'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
105+
${'1.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
106+
${'1.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
107+
${'^1'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
108+
${'^1.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
109+
${'^1.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
110+
${'~1'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
111+
${'~0.7'} | ${'replace'} | ${'0.7.3'} | ${'0.8.5'} | ${'~0.8'}
112+
${'~1.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
113+
${'~1.0.0'} | ${'pin'} | ${'1.0.0'} | ${'1.0.0'} | ${'=1.0.0'}
114+
${null} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${null}
115+
${'*'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'*'}
116+
${'=1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'}
117+
${' =1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'}
118+
${'= 1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'= 1.1.0'}
119+
${' = 1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'}
120+
${' = 1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'}
121+
${'= 1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'= 1.1.0'}
122+
${'1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'1.1.0'}
123+
${'^1.0'} | ${'bump'} | ${'1.0.0'} | ${'1.0.7'} | ${'^1.0.7'}
124+
${'^1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'2.0.7'} | ${'^2.0.0'}
125+
${'1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'2.0.7'} | ${'2.0.0'}
126+
${'^1'} | ${'bump'} | ${'1.0.0'} | ${'2.1.7'} | ${'^2.1.7'}
127+
${'~1'} | ${'bump'} | ${'1.0.0'} | ${'1.1.7'} | ${'~1.1.7'}
128+
${'5'} | ${'bump'} | ${'5.0.0'} | ${'5.1.7'} | ${'5.1.7'}
129+
${'5'} | ${'bump'} | ${'5.0.0'} | ${'6.1.7'} | ${'6.1.7'}
130+
${'5.0'} | ${'bump'} | ${'5.0.0'} | ${'5.0.7'} | ${'5.0.7'}
131+
${'5.0'} | ${'bump'} | ${'5.0.0'} | ${'5.1.7'} | ${'5.1.7'}
132+
${'5.0'} | ${'bump'} | ${'5.0.0'} | ${'6.1.7'} | ${'6.1.7'}
133+
${'0.5'} | ${'bump'} | ${'0.5.0'} | ${'0.5.1'} | ${'0.5.1'}
134+
${'0.5'} | ${'bump'} | ${'0.5.0'} | ${'0.6.1'} | ${'0.6.1'}
135+
${'1.2'} | ${'replace'} | ${'1.2.3'} | ${'1.3.0'} | ${'1.2'}
136+
${'5.0'} | ${'replace'} | ${'5.0.0'} | ${'5.1.7'} | ${'5.0'}
137+
${'5.0'} | ${'replace'} | ${'5.0.0'} | ${'6.1.7'} | ${'6.0'}
138+
${'0.5'} | ${'replace'} | ${'0.5.0'} | ${'0.6.1'} | ${'0.6'}
139+
${'=1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'1.1.0'} | ${'=1.1.0'}
140+
${'1.0.*'} | ${'replace'} | ${'1.0.0'} | ${'1.1.0'} | ${'1.1.*'}
141+
${'1.*'} | ${'replace'} | ${'1.0.0'} | ${'2.1.0'} | ${'2.*'}
142+
${'~0.6.1'} | ${'replace'} | ${'0.6.8'} | ${'0.7.0-rc.2'} | ${'~0.7.0-rc'}
143+
${'<1.3.4'} | ${'replace'} | ${'1.2.3'} | ${'1.5.0'} | ${'<1.5.1'}
144+
${'< 1.3.4'} | ${'replace'} | ${'1.2.3'} | ${'1.5.0'} | ${'< 1.5.1'}
145+
${'< 1.3.4'} | ${'replace'} | ${'1.2.3'} | ${'1.5.0'} | ${'< 1.5.1'}
146+
${'<=1.3.4'} | ${'replace'} | ${'1.2.3'} | ${'1.5.0'} | ${'<=1.5.0'}
147+
${'<= 1.3.4'} | ${'replace'} | ${'1.2.3'} | ${'1.5.0'} | ${'<= 1.5.0'}
148+
${'<= 1.3.4'} | ${'replace'} | ${'1.2.3'} | ${'1.5.0'} | ${'<= 1.5.0'}
149+
${'>= 0.1.21, < 0.2.0'} | ${'bump'} | ${'0.1.21'} | ${'0.1.24'} | ${'>= 0.1.24, < 0.2.0'}
150+
${'>= 0.1.21, <= 0.2.0'} | ${'bump'} | ${'0.1.21'} | ${'0.1.24'} | ${'>= 0.1.24, <= 0.2.0'}
151+
${'>= 0.0.1, <= 0.1'} | ${'bump'} | ${'0.0.1'} | ${'0.0.2'} | ${'>= 0.0.2, <= 0.1'}
152+
${'>= 1.2.3, <= 1'} | ${'bump'} | ${'1.2.3'} | ${'1.2.4'} | ${'>= 1.2.4, <= 1'}
153+
${'>= 1.2.3, <= 1.0'} | ${'bump'} | ${'1.2.3'} | ${'1.2.4'} | ${'>= 1.2.4, <= 1.2'}
154+
${'>= 0.0.1, < 0.1'} | ${'bump'} | ${'0.1.0'} | ${'0.2.1'} | ${'>= 0.2.1, < 0.3'}
155+
${'0.1.0+metadata'} | ${'bump'} | ${'0.1.0+metadata'} | ${'0.2.0+metadata'} | ${'0.2.0'}
156+
${'=0.1.0+metadata'} | ${'bump'} | ${'0.1.0+metadata'} | ${'0.2.0+metadata'} | ${'=0.2.0'}
157+
${'0.1.0+metadata'} | ${'replace'} | ${'0.1.0+metadata'} | ${'0.2.0+metadata'} | ${'0.2.0'}
155158
`(
156159
'getNewValue("$currentValue", "$rangeStrategy", "$currentVersion", "$newVersion") === "$expected"',
157160
({ currentValue, rangeStrategy, currentVersion, newVersion, expected }) => {

lib/modules/versioning/cargo/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ function getNewValue({
9191
currentValue,
9292
rangeStrategy,
9393
currentVersion,
94-
newVersion,
94+
newVersion: rawNewVersion,
9595
}: NewValueConfig): string {
96+
// Strip version metadata
97+
const newVersion = rawNewVersion.replace(/\+.*$/, '');
98+
9699
if (!currentValue || currentValue === '*') {
97100
return rangeStrategy === 'pin' ? `=${newVersion}` : currentValue;
98101
}

0 commit comments

Comments
 (0)