Skip to content

Commit f5f32bd

Browse files
authored
fix(pep440): handle v-prefixed versions gracefully (renovatebot#40989)
* fix(pep440): handle v-prefixed versions gracefully * Retain v-prefix * Fix test coverage and use named group
1 parent ad26a3a commit f5f32bd

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ describe('modules/versioning/pep440/index', () => {
101101
currentValue | rangeStrategy | currentVersion | newVersion | expected
102102
${'1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
103103
${'1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'1.2.3'}
104+
${'v1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'v1.2.3'}
105+
${'v1.0.0'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'v1.2.3'}
104106
${'==1.0.3'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'==1.2.3'}
105107
${'==1.0.3'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'==1.2.3'}
106108
${'>=1.2.0'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'>=1.2.3'}

lib/modules/versioning/pep440/range.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,24 @@ describe('modules/versioning/pep440/range', () => {
3535
);
3636
expect(logger.warn).not.toHaveBeenCalled();
3737
});
38+
39+
it('handles v-prefixed version as currentValue', () => {
40+
const res = getNewValue({
41+
currentValue: 'v0.7.15',
42+
rangeStrategy: 'auto',
43+
newVersion: '0.8.0',
44+
currentVersion: '0.7.15',
45+
});
46+
expect(res).toBe('v0.8.0');
47+
});
48+
49+
it('handles bare version that differs from currentVersion without v-prefix', () => {
50+
const res = getNewValue({
51+
currentValue: '1.0.0.0',
52+
rangeStrategy: 'auto',
53+
newVersion: '1.2.3',
54+
currentVersion: '1.0.0',
55+
});
56+
expect(res).toBe('1.2.3');
57+
});
3858
});

lib/modules/versioning/pep440/range.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ export function getNewValue({
117117
return newVersion;
118118
}
119119

120+
// Handle bare versions (e.g., "v0.7.15") that don't strictly equal
121+
// currentVersion due to normalization, treating them as pinned while
122+
// preserving the v-prefix.
123+
if (parseVersion(currentValue)) {
124+
const vPrefix = regEx(/^(?<prefix>[vV])/).exec(currentValue);
125+
if (vPrefix) {
126+
return `${vPrefix.groups!.prefix}${newVersion}`;
127+
}
128+
return newVersion;
129+
}
130+
120131
try {
121132
ranges = parseCurrentRange(currentValue);
122133
if (!ranges.length) {

0 commit comments

Comments
 (0)