File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -442,7 +442,20 @@ def load_config(config_file)
442442 valid_file = file . exist? && !file . size . zero?
443443 return { } unless valid_file
444444 require_relative "yaml_serializer"
445- YAMLSerializer . load file . read
445+ YAMLSerializer . load ( file . read ) . inject ( { } ) do |config , ( k , v ) |
446+ new_k = k
447+
448+ if k . include? ( "-" )
449+ Bundler . ui . warn "Your #{ file } config includes `#{ k } `, which contains the dash character (`-`).\n " \
450+ "This is deprecated, because configuration through `ENV` should be possible, but `ENV` keys cannot include dashes.\n " \
451+ "Please edit #{ file } and replace any dashes in configuration keys with a triple underscore (`___`)."
452+
453+ new_k = k . gsub ( "-" , "___" )
454+ end
455+
456+ config [ new_k ] = v
457+ config
458+ end
446459 end
447460 end
448461
Original file line number Diff line number Diff line change 312312 describe "BUNDLE_ keys format" do
313313 let ( :settings ) { described_class . new ( bundled_app ( ".bundle" ) ) }
314314
315- it "converts older keys without double dashes " do
315+ it "converts older keys without double underscore " do
316316 config ( "BUNDLE_MY__PERSONAL.RACK" => "~/Work/git/rack" )
317317 expect ( settings [ "my.personal.rack" ] ) . to eq ( "~/Work/git/rack" )
318318 end
319319
320- it "converts older keys without trailing slashes and double dashes " do
320+ it "converts older keys without trailing slashes and double underscore " do
321321 config ( "BUNDLE_MIRROR__HTTPS://RUBYGEMS.ORG" => "http://rubygems-mirror.org" )
322322 expect ( settings [ "mirror.https://rubygems.org/" ] ) . to eq ( "http://rubygems-mirror.org" )
323323 end
324324
325+ it "converts older keys with dashes" do
326+ config ( "BUNDLE_MY-PERSONAL-SERVER__ORG" => "my-personal-server.org" )
327+ expect ( Bundler . ui ) . to receive ( :warn ) . with (
328+ "Your #{ bundled_app ( ".bundle/config" ) } config includes `BUNDLE_MY-PERSONAL-SERVER__ORG`, which contains the dash character (`-`).\n " \
329+ "This is deprecated, because configuration through `ENV` should be possible, but `ENV` keys cannot include dashes.\n " \
330+ "Please edit #{ bundled_app ( ".bundle/config" ) } and replace any dashes in configuration keys with a triple underscore (`___`)."
331+ )
332+ expect ( settings [ "my-personal-server.org" ] ) . to eq ( "my-personal-server.org" )
333+ end
334+
325335 it "reads newer keys format properly" do
326336 config ( "BUNDLE_MIRROR__HTTPS://RUBYGEMS__ORG/" => "http://rubygems-mirror.org" )
327337 expect ( settings [ "mirror.https://rubygems.org/" ] ) . to eq ( "http://rubygems-mirror.org" )
You can’t perform that action at this time.
0 commit comments