ruby-changes:61492
From: David <ko1@a...>
Date: Fri, 5 Jun 2020 07:33:22 +0900 (JST)
Subject: [ruby-changes:61492] 09602f4301 (master): [rubygems/rubygems] Revert multi ruby{, gems} version requirement fix
https://git.ruby-lang.org/ruby.git/commit/?id=09602f4301 From 09602f4301ccf64d1b27e62d71f00569d1d78a72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Wed, 27 May 2020 18:30:46 +0200 Subject: [rubygems/rubygems] Revert multi ruby{,gems} version requirement fix This reverts commit 20f06d9e178211a3016133852b72d21ac7bb93ad, reversing changes made to f2b30cb70df8a518bef0e8a64bbceb86234d922d. https://github.com/rubygems/rubygems/commit/40802bdb18 diff --git a/lib/bundler/compact_index_client/cache.rb b/lib/bundler/compact_index_client/cache.rb index ef8517e..f6105d3 100644 --- a/lib/bundler/compact_index_client/cache.rb +++ b/lib/bundler/compact_index_client/cache.rb @@ -1,7 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/compact_index_client/cache.rb#L1 # frozen_string_literal: true -require_relative "gem_parser" - module Bundler class CompactIndexClient class Cache @@ -94,9 +92,19 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/compact_index_client/cache.rb#L92 header ? lines[header + 1..-1] : lines end - def parse_gem(line) - @gem_parser ||= GemParser.new - @gem_parser.parse(line) + def parse_gem(string) + version_and_platform, rest = string.split(" ", 2) + version, platform = version_and_platform.split("-", 2) + dependencies, requirements = rest.split("|", 2).map {|s| s.split(",") } if rest + dependencies = dependencies ? dependencies.map {|d| parse_dependency(d) } : [] + requirements = requirements ? requirements.map {|r| parse_dependency(r) } : [] + [version, platform, dependencies, requirements] + end + + def parse_dependency(string) + dependency = string.split(":") + dependency[-1] = dependency[-1].split("&") if dependency.size > 1 + dependency end def info_roots diff --git a/lib/bundler/compact_index_client/gem_parser.rb b/lib/bundler/compact_index_client/gem_parser.rb deleted file mode 100644 index 117da64..0000000 --- a/lib/bundler/compact_index_client/gem_parser.rb +++ /dev/null @@ -1,66 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/compact_index_client/cache.rb#L0 -# frozen_string_literal: true - -module Bundler - class CompactIndexClient - class GemParser - def parse(line) - version_and_platform, rest = line.split(" ", 2) - version, platform = version_and_platform.split("-", 2) - dependencies, requirements = rest.split("|", 2) if rest - dependencies = dependencies ? parse_dependencies(dependencies) : [] - requirements = requirements ? parse_requirements(requirements) : [] - [version, platform, dependencies, requirements] - end - - private - - def parse_dependencies(raw_dependencies) - raw_dependencies.split(",").map {|d| parse_dependency(d) } - end - - def parse_dependency(raw_dependency) - dependency = raw_dependency.split(":") - dependency[-1] = dependency[-1].split("&") if dependency.size > 1 - dependency - end - - # Parse the following format: - # - # line = "checksum:#{checksum}" - # line << ",ruby:#{ruby_version}" if ruby_version && ruby_version != ">= 0" - # line << ",rubygems:#{rubygems_version}" if rubygems_version && rubygems_version != ">= 0" - # - # See compact_index/gem_version.rb for details. - # - # We can't use parse_dependencies for requirements because "," in - # ruby_version and rubygems_version isn't escaped as "&". For example, - # "checksum:XXX,ruby:>=2.2, < 2.7.dev" can't be parsed as expected. - def parse_requirements(raw_requirements) - requirements = [] - checksum = raw_requirements.match(/\A(checksum):([^,]+)/) - if checksum - requirements << [checksum[1], [checksum[2]]] - raw_requirements = checksum.post_match - if raw_requirements.start_with?(",") - raw_requirements = raw_requirements[1..-1] - end - end - rubygems = raw_requirements.match(/(rubygems):(.+)\z/) - if rubygems - raw_requirements = rubygems.pre_match - if raw_requirements.start_with?(",") - raw_requirements = raw_requirements[1..-1] - end - end - ruby = raw_requirements.match(/\A(ruby):(.+)\z/) - if ruby - requirements << [ruby[1], ruby[2].split(/\s*,\s*/)] - end - if rubygems - requirements << [rubygems[1], rubygems[2].split(/\s*,\s*/)] - end - requirements - end - end - end -end diff --git a/spec/bundler/bundler/compact_index_client/gem_parser_spec.rb b/spec/bundler/bundler/compact_index_client/gem_parser_spec.rb deleted file mode 100644 index 5f53054..0000000 --- a/spec/bundler/bundler/compact_index_client/gem_parser_spec.rb +++ /dev/null @@ -1,174 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/compact_index_client/cache.rb#L0 -# frozen_string_literal: true - -require "bundler/compact_index_client/gem_parser" - -RSpec.describe Bundler::CompactIndexClient::GemParser do - def parse(line) - parser = Bundler::CompactIndexClient::GemParser.new - parser.parse(line) - end - - context "platform" do - it "existent" do - checksum = "d5956d2bcb509af2cd07c90d9e5fdb331be8845a75bfd823a31c147b52cff471" - line = "1.11.3-java |checksum:#{checksum}" - expected = [ - "1.11.3", - "java", - [], - [ - ["checksum", [checksum]], - ], - ] - expect(parse(line)).to eq expected - end - - it "nonexistent" do - checksum = "6da2eb3c4867e64df28d3e0b1008422dfacda7c046f9a8f3c56c52505b195e81" - line = "1.11.3 |checksum:#{checksum}" - expected = [ - "1.11.3", - nil, - [], - [ - ["checksum", [checksum]], - ], - ] - expect(parse(line)).to eq expected - end - end - - context "dependencies" do - it "nothing" do - checksum = "6da2eb3c4867e64df28d3e0b1008422dfacda7c046f9a8f3c56c52505b195e81" - line = "1.11.3 |checksum:#{checksum}" - expected = [ - "1.11.3", - nil, - [], - [ - ["checksum", [checksum]], - ], - ] - expect(parse(line)).to eq expected - end - - it "one" do - checksum = "5f0b378d12ab5665e2b6a1525274de97350238963002583cf088dae988527647" - line = "0.3.2 bones:>= 2.4.2|checksum:#{checksum}" - expected = [ - "0.3.2", - nil, - [ - ["bones", [">= 2.4.2"]], - ], - [ - ["checksum", [checksum]], - ], - ] - expect(parse(line)).to eq expected - end - - it "multiple" do - checksum = "199e892ada86c44d1f2e110b822d5da46b52fa2cbd2f00d89695b4cf610f9927" - line = "3.1.2 native-package-installer:>= 0,pkg-config:>= 0|checksum:#{checksum}" - expected = [ - "3.1.2", - nil, - [ - ["native-package-installer", [">= 0"]], - ["pkg-config", [">= 0"]], - ], - [ - ["checksum", [checksum]], - ], - ] - expect(parse(line)).to eq expected - end - - context "version" do - it "multiple" do - checksum = "1ec894b8090cb2c9393153552be2f3b6b1975265cbc1e0a3c6b28ebfea7e76a1" - line = "3.1.5 multi_json:< 1.3&>= 1.0|checksum:#{checksum}" - expected = [ - "3.1.5", - nil, - [ - ["multi_json", ["< 1.3", ">= 1.0"]], - ], - [ - ["checksum", [checksum]], - ], - ] - expect(parse(line)).to eq expected - end - end - end - - context "requirements" do - context "ruby" do - it "one version" do - checksum ="6da2eb3c4867e64df28d3e0b1008422dfacda7c046f9a8f3c56c52505b195e81" - line = "1.11.3 |checksum:#{checksum},ruby:>= 2.0" - expected = [ - "1.11.3", - nil, - [], - [ - ["checksum", [checksum]], - ["ruby", [">= 2.0"]], - ], - ] - expect(parse(line)).to eq expected - end - - it "multiple versions" do - checksum = "99e4845796c8dec1c3fc80dc772860a01633b33291bd7534007f5c7724f0b876" - line = "1.11.3-x86-mingw32 |checksum:#{checksum},ruby:>= 2.2, < 2.7.dev" - expected = [ - "1.11.3", - "x86-mingw32", - [], - [ - ["checksum", [checksum]], - ["ruby", [">= 2.2", "< 2.7.dev"]], - ], - ] - expect(parse(line)).to eq expected - end - - it "with rubygems" do - checksum = "7a82b358f00da749b01f8c84df8e8eb21c1bc389740aab9a2bf4ce59894564ac" - line = "1.9.23.pre1 |checksum:#{checksum},ruby:>= 1.9, < 2.7.dev,rubygems:> 1.3.1" - expected = [ - "1.9.23.pre1", - nil, - [], - [ - ["checksum", [checksum]], - ["ruby", [">= 1.9", "< 2.7.dev"]], - ["rubygems", ["> 1.3.1"]], - ], - ] - expect(parse(line)).to eq expected - end - end - - context "rubygems" do - it "existent" do - checksum = "91ddb4c1b5482a4aff957f6733e282ce2767b2d3051138e0203e39d6df4eba10" - line = "1.0.12.pre |checksum:#{checksum},rubygems:> 1.3.1" - expected = [ - "1.0.12.pre", - nil, - [], - [ - ["checksum", [checksum]], - ["rubygems", ["> 1.3.1"]], - ], - ] - expect(parse(line)).to eq expected - end - end - end -end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/