[rubygems/rubygems] Skip to load commented out words

https://github.com/rubygems/rubygems/commit/e6a9148ba2
This commit is contained in:
Hiroshi SHIBATA 2024-01-23 19:14:39 +09:00 committed by git
parent 53d0cf442a
commit 1018dca09a
4 changed files with 18 additions and 1 deletions

View File

@ -56,6 +56,7 @@ module Bundler
last_hash = nil
last_empty_key = nil
str.split(/\r?\n/) do |line|
line = line.split("#", 2).first.strip if line.include?("#")
if match = HASH_REGEX.match(line)
indent, key, quote, val = match.captures
convert_to_backward_compatible_key!(key)

View File

@ -56,6 +56,7 @@ module Gem
last_hash = nil
last_empty_key = nil
str.split(/\r?\n/) do |line|
line = line.split("#", 2).first.strip if line.include?("#")
if match = HASH_REGEX.match(line)
indent, key, quote, val = match.captures
convert_to_backward_compatible_key!(key)

View File

@ -174,6 +174,21 @@ RSpec.describe Bundler::YAMLSerializer do
expect(serializer.load(yaml)).to eq(hash)
end
it "skip commented out words" do
yaml = <<~YAML
---
foo: "bar"
buzz: # "foo"
YAML
hash = {
"foo" => "bar",
"buzz" => {},
}
expect(serializer.load(yaml)).to eq(hash)
end
end
describe "against yaml lib" do

View File

@ -439,7 +439,7 @@ E
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(out).to be_empty
expect(err).to be_empty
ruby(<<~RUBY)