ruby-changes:62464
From: Jean <ko1@a...>
Date: Fri, 31 Jul 2020 21:08:30 +0900 (JST)
Subject: [ruby-changes:62464] 561576367b (master): [rubygems/rubygems] Deduplicate the requirement operators in memory
https://git.ruby-lang.org/ruby.git/commit/?id=561576367b From 561576367beeb1237a3821db1b0ab9ef66e9fb56 Mon Sep 17 00:00:00 2001 From: Jean Boussier <jean.boussier@g...> Date: Thu, 23 Jul 2020 15:11:24 +0200 Subject: [rubygems/rubygems] Deduplicate the requirement operators in memory https://github.com/rubygems/rubygems/commit/9963d33cf2 diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb index 65bc837..d9d7c2f 100644 --- a/lib/rubygems/requirement.rb +++ b/lib/rubygems/requirement.rb @@ -111,7 +111,7 @@ class Gem::Requirement https://github.com/ruby/ruby/blob/trunk/lib/rubygems/requirement.rb#L111 elsif $1 == ">=" && $2 == "0.a" DefaultPrereleaseRequirement else - [$1 || "=", Gem::Version.new($2)] + [-($1 || "="), Gem::Version.new($2)] end end diff --git a/test/rubygems/test_gem_requirement.rb b/test/rubygems/test_gem_requirement.rb index 55a902d..af9d807 100644 --- a/test/rubygems/test_gem_requirement.rb +++ b/test/rubygems/test_gem_requirement.rb @@ -81,6 +81,12 @@ class TestGemRequirement < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_requirement.rb#L81 Gem::Requirement.parse(Gem::Version.new('2')) end + if RUBY_VERSION >= '2.5' + def test_parse_deduplication + assert_same '~>', Gem::Requirement.parse('~> 1').first + end + end + def test_parse_bad [ nil, -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/