Skip to content

Commit

Permalink
[rubygems/rubygems] Don't upcase Windows ENV when backing it up
Browse files Browse the repository at this point in the history
I apparently did that to fix some issue with case insensitivity but I
didn't add a spec, and I think not upcasing should not cause issues.

rubygems/rubygems@1b6f23275a
  • Loading branch information
deivid-rodriguez authored and matzbot committed Apr 25, 2024
1 parent 2871376 commit 5d2fb5d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
9 changes: 1 addition & 8 deletions lib/bundler/environment_preserver.rb
Expand Up @@ -19,14 +19,7 @@ class EnvironmentPreserver
BUNDLER_PREFIX = "BUNDLER_ORIG_"

def self.from_env
new(env_to_hash(ENV), BUNDLER_KEYS)
end

def self.env_to_hash(env)
to_hash = env.to_hash
return to_hash unless Gem.win_platform?

to_hash.each_with_object({}) {|(k,v), a| a[k.upcase] = v }
new(ENV.to_hash, BUNDLER_KEYS)
end

# @param env [Hash]
Expand Down
18 changes: 18 additions & 0 deletions spec/bundler/runtime/inline_spec.rb
Expand Up @@ -638,4 +638,22 @@ def confirm(msg, newline = nil)

expect(out).to include("Installing timeout 999")
end

it "does not upcase ENV" do
script <<-RUBY
require 'bundler/inline'
ENV['Test_Variable'] = 'value string'
puts("before: \#{ENV.each_key.select { |key| key.match?(/test_variable/i) }}")
gemfile do
source "#{file_uri_for(gem_repo1)}"
end
puts("after: \#{ENV.each_key.select { |key| key.match?(/test_variable/i) }}")
RUBY

expect(out).to include("before: [\"Test_Variable\"]")
expect(out).to include("after: [\"Test_Variable\"]")
end
end
6 changes: 3 additions & 3 deletions spec/bundler/runtime/with_unbundled_env_spec.rb
Expand Up @@ -139,7 +139,7 @@ def run_bundler_script(env, script)
describe "Bundler.with_original_env" do
it "should set ENV to original_env in the block" do
expected = Bundler.original_env
actual = Bundler.with_original_env { Bundler::EnvironmentPreserver.env_to_hash(ENV) }
actual = Bundler.with_original_env { ENV.to_hash }
expect(actual).to eq(expected)
end

Expand All @@ -157,7 +157,7 @@ def run_bundler_script(env, script)
expected = Bundler.unbundled_env

actual = Bundler.ui.silence do
Bundler.with_clean_env { Bundler::EnvironmentPreserver.env_to_hash(ENV) }
Bundler.with_clean_env { ENV.to_hash }
end

expect(actual).to eq(expected)
Expand All @@ -175,7 +175,7 @@ def run_bundler_script(env, script)
describe "Bundler.with_unbundled_env" do
it "should set ENV to unbundled_env in the block" do
expected = Bundler.unbundled_env
actual = Bundler.with_unbundled_env { Bundler::EnvironmentPreserver.env_to_hash(ENV) }
actual = Bundler.with_unbundled_env { ENV.to_hash }
expect(actual).to eq(expected)
end

Expand Down

0 comments on commit 5d2fb5d

Please sign in to comment.