diff options
author | Stefan Lance <stefan@lances.net> | 2015-07-16 12:52:47 -0500 |
---|---|---|
committer | Stefan Lance <stefan@lances.net> | 2015-07-17 12:53:51 -0500 |
commit | a9288a5903c803253d0dfe2d9f8692213a5b641a (patch) | |
tree | 70a13de90ab9fbb26ee9e221907a8b5721ef3245 | |
parent | 4d214d01303419325bb03a2c9266373b6581ba3e (diff) | |
download | bundler-a9288a5903c803253d0dfe2d9f8692213a5b641a.tar.gz |
Undo changes in initial "stop autoremembering flags" commit
Conflicts:
lib/bundler/settings.rb
-rw-r--r-- | lib/bundler/settings.rb | 41 | ||||
-rw-r--r-- | spec/bundler/settings_spec.rb | 18 |
2 files changed, 6 insertions, 53 deletions
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index aca3a09286..aa6b07b609 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -2,20 +2,19 @@ require "uri" module Bundler class Settings - BOOL_KEYS = %w(frozen cache_all no_prune disable_local_branch_check ignore_messages ignore_warnings gem.mit gem.coc).freeze + BOOL_KEYS = %w(frozen cache_all no_prune disable_local_branch_check ignore_messages gem.mit gem.coc).freeze NUMBER_KEYS = %w(retry timeout redirect).freeze DEFAULT_CONFIG = {:retry => 3, :timeout => 10, :redirect => 5} def initialize(root = nil) @root = root - @current_config = {} @local_config = load_config(local_config_file) @global_config = load_config(global_config_file) end def [](name) key = key_for(name) - value = (@current_config[key] || @local_config[key] || ENV[key] || @global_config[key] || DEFAULT_CONFIG[name]) + value = (@local_config[key] || ENV[key] || @global_config[key] || DEFAULT_CONFIG[name]) case when !value.nil? && is_bool(name) @@ -27,30 +26,13 @@ module Bundler end end - # In Bundler pre 2.0 any command ever set was stored in the local config - # file. In Bundler 2.0 they are only saved for that current command and - # `bundle config <setting name> <setting value>` is used for setting - # remembered arguments. - # See https://trello.com/c/yGsPNDpg def []=(key, value) - @use_current ||= (Bundler::VERSION.split(".")[0].to_i >= 2) - if @use_current - set_current(key, value) - else - set_local(key, value) - end - end - - def set_current(key, value) - key = key_for key - @current_config[key] = value - end - - def set_local(key, value) local_config_file or raise GemfileNotFound, "Could not locate Gemfile" set_key(key, value, @local_config, local_config_file) end + alias :set_local :[]= + def delete(key) @local_config.delete(key_for(key)) end @@ -62,10 +44,10 @@ module Bundler def all env_keys = ENV.keys.select { |k| k =~ /BUNDLE_.*/ } - keys = @current_config.keys | @global_config.keys | @local_config.keys | env_keys | DEFAULT_CONFIG.keys + keys = @global_config.keys | @local_config.keys | env_keys keys.map do |key| - key.to_s.sub(/^BUNDLE_/, "").gsub(/__/, ".").downcase + key.sub(/^BUNDLE_/, '').gsub(/__/, ".").downcase end end @@ -104,7 +86,6 @@ module Bundler def locations(key) key = key_for(key) locations = {} - locations[:current] = @current_config[key] if @current_config.key?(key) locations[:local] = @local_config[key] if @local_config.key?(key) locations[:env] = ENV[key] if ENV[key] locations[:global] = @global_config[key] if @global_config.key?(key) @@ -117,10 +98,6 @@ module Bundler locations = [] if @local_config.key?(key) - locations << "Set only for this command using command line arguments" - end - - if @local_config.key?(key) locations << "Set for your local app (#{local_config_file}): #{@local_config[key].inspect}" end @@ -132,10 +109,6 @@ module Bundler locations << "Set for the current user (#{global_config_file}): #{@global_config[key].inspect}" end - if DEFAULT_CONFIG.key?(exposed_key) - locations << "Set by default: #{DEFAULT_CONFIG[key].inspect}" - end - return ["You have not configured a value for `#{exposed_key}`"] if locations.empty? locations end @@ -244,8 +217,6 @@ module Bundler end value - rescue Errno::EACCES - raise PermissionError.new(file) end def global_config_file diff --git a/spec/bundler/settings_spec.rb b/spec/bundler/settings_spec.rb index 80236293dd..3578155265 100644 --- a/spec/bundler/settings_spec.rb +++ b/spec/bundler/settings_spec.rb @@ -15,24 +15,6 @@ describe Bundler::Settings do end end - describe "#[]=" do - if Bundler::VERSION.split(".")[0].to_i >= 2 - context "when on Bundler 2.0" do - it "should not write to local config file" do - settings[:foo] = :bar - expect(settings.locations(:foo)[:local]).to be_nil - end - end - else - context "when not on Bundler 2.0" do - it "should not write to local config file" do - settings[:foo] = :bar - expect(settings.locations(:foo)[:local]).to eq(:bar) - end - end - end - end - describe "#[]" do context "when not set" do context "when default value present" do |