summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Arko <mail@arko.net>2015-07-18 14:02:23 -0600
committerAndré Arko <mail@arko.net>2015-07-18 14:02:23 -0600
commit92db084a7006ecb0a142df4c83742e3d09b919a1 (patch)
treec1cc42a3fcffbca63dd25a2709b7a3c1bef3c337
parent680e91cdb167a5400dc6157d4913f90a96269ecd (diff)
parenta9288a5903c803253d0dfe2d9f8692213a5b641a (diff)
downloadbundler-92db084a7006ecb0a142df4c83742e3d09b919a1.tar.gz
Merge pull request #3836 from smlance/sml-undo-forgetting-flags-2-0-dev
Undo changes in initial "stop autoremembering flags" commit
-rw-r--r--lib/bundler/settings.rb41
-rw-r--r--spec/bundler/settings_spec.rb18
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