[rubygems/rubygems] Properly restore empty env vars

https://github.com/rubygems/rubygems/commit/e0d68a8688
This commit is contained in:
David Rodríguez 2024-01-15 15:03:29 +01:00 коммит произвёл Hiroshi SHIBATA
Родитель 2956d3a511
Коммит 355480dec6
2 изменённых файлов: 14 добавлений и 6 удалений

Просмотреть файл

@ -58,7 +58,7 @@ module Bundler
env = @original.clone
@keys.each do |key|
value = env[key]
if !value.nil? && !value.empty?
if !value.nil?
env[@prefix + key] ||= value
elsif value.nil?
env[@prefix + key] ||= INTENTIONALLY_NIL
@ -72,7 +72,7 @@ module Bundler
env = @original.clone
@keys.each do |key|
value_original = env[@prefix + key]
next if value_original.nil? || value_original.empty?
next if value_original.nil?
if value_original == INTENTIONALLY_NIL
env.delete(key)
else

Просмотреть файл

@ -27,8 +27,12 @@ RSpec.describe Bundler::EnvironmentPreserver do
context "when a key is empty" do
let(:env) { { "foo" => "" } }
it "should not create backup entries" do
expect(subject).not_to have_key "BUNDLER_ORIG_foo"
it "should keep the original entry" do
expect(subject["foo"]).to be_empty
end
it "should still create backup entries" do
expect(subject).to have_key "BUNDLER_ORIG_foo"
end
end
@ -71,8 +75,12 @@ RSpec.describe Bundler::EnvironmentPreserver do
context "when the original key is empty" do
let(:env) { { "foo" => "my-foo", "BUNDLER_ORIG_foo" => "" } }
it "should keep the current value" do
expect(subject["foo"]).to eq("my-foo")
it "should restore the original value" do
expect(subject["foo"]).to be_empty
end
it "should delete the backup value" do
expect(subject.key?("BUNDLER_ORIG_foo")).to eq(false)
end
end
end