diff options
author | Stefan Lance <stefan@lances.net> | 2015-06-28 16:28:17 -0400 |
---|---|---|
committer | Stefan Lance <stefan@lances.net> | 2015-07-01 18:57:08 -0500 |
commit | 91d23ea3ee62868946d872b6b112ad62307af458 (patch) | |
tree | 800c5744487c4b0a4cb3e0d15f4c95d859cd0156 | |
parent | 851bb0c8170efc1d169f95eda30a61a99f30fb06 (diff) | |
download | bundler-91d23ea3ee62868946d872b6b112ad62307af458.tar.gz |
Handle conflicting path config settings
- behavior may be undefined if the user sets both manually in their
config file
-rw-r--r-- | lib/bundler/cli/config.rb | 12 | ||||
-rw-r--r-- | spec/commands/config_spec.rb | 26 |
2 files changed, 38 insertions, 0 deletions
diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb index 436255844e..35f240ed82 100644 --- a/lib/bundler/cli/config.rb +++ b/lib/bundler/cli/config.rb @@ -49,6 +49,18 @@ module Bundler new_value = args.join(" ") locations = Bundler.settings.locations(name) + + if name == "path.system" and Bundler.settings[:path] and new_value == "true" + Bundler.ui.warn "`path` is already configured, so it will be unset." + Bundler.settings.set_local("path", nil) + Bundler.settings.set_global("path", nil) + elsif name == "path" and Bundler.settings["path.system"] + Bundler.ui.warn "`path.system` is already configured, so it will be unset." + Bundler.settings.set_local("path.system", nil) + Bundler.settings.set_global("path.system", nil) + end + + if scope == "global" if locations[:local] Bundler.ui.info "Your application has set #{name} to #{locations[:local].inspect}. " \ diff --git a/spec/commands/config_spec.rb b/spec/commands/config_spec.rb index 9ee4994b9e..239ec67e0a 100644 --- a/spec/commands/config_spec.rb +++ b/spec/commands/config_spec.rb @@ -282,6 +282,32 @@ E expect(out).to match(long_string_without_special_characters) end end + + describe "conflicting path settings" do + before(:each) { bundle :install } + + describe "setting `path` when `path.system` is already set" do + it "should print a warning and remove the `path.system` setting" do + bundle "config path.system true" + bundle "config path 'some/path/'" + + expect(out).to include("`path.system` is already configured") + run "puts Bundler.settings['path.system'] == nil" + expect(out).to eq("true") + end + end + + describe "setting `path.system` when `path` is already set" do + it "should print a warning and remove the `path` setting" do + bundle "config path 'some/path/'" + bundle "config path.system true" + + expect(out).to include("`path` is already configured") + run "puts Bundler.settings[:path] == nil" + expect(out).to eq("true") + end + end + end end describe "setting gemfile via config" do |