Skip to content

Commit 7314557

Browse files
fix(versioning/ruby): prevent extra vv prefix addition (#35667)
1 parent 5b9e228 commit 7314557

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ describe('modules/versioning/ruby/index', () => {
253253
it.each`
254254
currentValue | rangeStrategy | currentVersion | newVersion | expected
255255
${'1.0.3'} | ${'pin'} | ${'1.0.3'} | ${'1.2.3'} | ${'1.2.3'}
256+
${'v1.0.3'} | ${'auto'} | ${'v1.0.3'} | ${'v1.2.3'} | ${'v1.2.3'}
256257
${'v1.0.3'} | ${'pin'} | ${'1.0.3'} | ${'1.2.3'} | ${'v1.2.3'}
257258
${'= 1.0.3'} | ${'pin'} | ${'1.0.3'} | ${'1.2.3'} | ${'= 1.2.3'}
258259
${'!= 1.0.3'} | ${'pin'} | ${'1.0.4'} | ${'1.2.3'} | ${'1.2.3'}

lib/modules/versioning/ruby/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ const getNewValue = ({
103103
}: NewValueConfig): string | null => {
104104
let newValue = null;
105105
if (isVersion(currentValue)) {
106-
newValue = currentValue.startsWith('v') ? 'v' + newVersion : newVersion;
106+
newValue =
107+
currentValue.startsWith('v') && !newVersion.startsWith('v')
108+
? `v${newVersion}`
109+
: newVersion;
107110
} else if (currentValue.replace(regEx(/^=\s*/), '') === currentVersion) {
108111
newValue = currentValue.replace(currentVersion, newVersion);
109112
} else {

0 commit comments

Comments
 (0)