diff options
author | Stefan Lance <stefan@lances.net> | 2015-06-28 16:28:17 -0400 |
---|---|---|
committer | Samuel E. Giddins <segiddins@segiddins.me> | 2015-07-16 16:52:00 -0700 |
commit | debb282df11aebf1dabab9f48a7a4e088093e2e2 (patch) | |
tree | d0248da4fd10e763f11ff13da9b3ac82d632d1ac | |
parent | e764a6e8df71263442f889343e78965eba3be8b6 (diff) | |
download | bundler-debb282df11aebf1dabab9f48a7a4e088093e2e2.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 7dcdea3f1c..444c304ec3 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 33134bef0c..eab709390e 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 |