ruby-changes:72019
From: David <ko1@a...>
Date: Mon, 30 May 2022 17:43:21 +0900 (JST)
Subject: [ruby-changes:72019] d6684f063b (master): [rubygems/rubygems] Fix crash when commenting out a mirror in configuration
https://git.ruby-lang.org/ruby.git/commit/?id=d6684f063b From d6684f063bc53e3cab025bd39526eca3b480b5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Sat, 28 May 2022 18:37:41 +0200 Subject: [rubygems/rubygems] Fix crash when commenting out a mirror in configuration https://github.com/rubygems/rubygems/commit/2d99277328 --- lib/bundler/settings.rb | 2 +- spec/bundler/commands/config_spec.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 8f263cd012..398c66055a 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -487,7 +487,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/settings.rb#L487 /ix.freeze def self.key_for(key) - key = normalize_uri(key).to_s if key.is_a?(String) && /https?:/ =~ key + key = normalize_uri(key).to_s if key.is_a?(String) && key.start_with?("http", "mirror.http") key = key.to_s.gsub(".", "__").gsub("-", "___").upcase "BUNDLE_#{key}" end diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb index fb7aa3cc67..6148b1c7ce 100644 --- a/spec/bundler/commands/config_spec.rb +++ b/spec/bundler/commands/config_spec.rb @@ -435,6 +435,34 @@ E https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/config_spec.rb#L435 end end + describe "commented out settings with urls" do + before do + bundle "config set #mirror.https://rails-assets.org http://localhost:9292" + end + + it "does not make bundler crash and ignores the configuration" do + bundle "config list --parseable" + + expect(out).to eq("#mirror.https://rails-assets.org/=http://localhost:9292") + expect(err).to be_empty + + ruby(<<~RUBY) + require "#{entrypoint}" + print Bundler.settings.mirror_for("https://rails-assets.org") + RUBY + expect(out).to eq("https://rails-assets.org/") + expect(err).to be_empty + + bundle "config set mirror.all http://localhost:9293" + ruby(<<~RUBY) + require "#{entrypoint}" + print Bundler.settings.mirror_for("https://rails-assets.org") + RUBY + expect(out).to eq("http://localhost:9293/") + expect(err).to be_empty + end + end + describe "subcommands" do it "list" do bundle "config list", :env => { "BUNDLE_FOO" => "bar" } -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/