diff --git a/lib/versioning/ruby/index.ts b/lib/versioning/ruby/index.ts index 6778528869f2e7..0da4b089940c0d 100644 --- a/lib/versioning/ruby/index.ts +++ b/lib/versioning/ruby/index.ts @@ -69,13 +69,16 @@ const minSatisfyingVersion = (versions: string[], range: string): string => const getNewValue = ( currentValue: string, rangeStrategy: RangeStrategy, - _fromVersion: string, + fromVersion: string, toVersion: string ): string => { let result = null; if (isVersion(currentValue)) { return currentValue.startsWith('v') ? 'v' + toVersion : toVersion; } + if (currentValue.replace(/^=\s*/, '') === fromVersion) { + return currentValue.replace(fromVersion, toVersion); + } switch (rangeStrategy) { case 'pin': result = pin({ to: vtrim(toVersion) }); diff --git a/test/versioning/ruby.spec.ts b/test/versioning/ruby.spec.ts index 1fd0771805cda8..1bc303b860c001 100644 --- a/test/versioning/ruby.spec.ts +++ b/test/versioning/ruby.spec.ts @@ -357,7 +357,7 @@ describe('semverRuby', () => { [ ['1.2.3', '1.0.3', 'pin', '1.0.3', '1.2.3'], ['v1.2.3', 'v1.0.3', 'pin', '1.0.3', '1.2.3'], - ['1.2.3', '= 1.0.3', 'pin', '1.0.3', '1.2.3'], + ['= 1.2.3', '= 1.0.3', 'pin', '1.0.3', '1.2.3'], ['1.2.3', '!= 1.0.3', 'pin', '1.0.4', '1.2.3'], ['1.2.3', '> 1.0.3', 'pin', '1.0.4', '1.2.3'], ['1.2.3', '< 1.0.3', 'pin', '1.0.2', '1.2.3'], @@ -431,6 +431,11 @@ describe('semverRuby', () => { semverRuby.getNewValue('~> 1', 'replace', '1.2.0', '2.0.3') ).toEqual('~> 2'); }); + it('handles explicit equals', () => { + expect( + semverRuby.getNewValue('= 5.2.2', 'replace', '5.2.2', '5.2.2.1') + ).toEqual('= 5.2.2.1'); + }); it('returns correct version for replace strategy', () => { [