summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTerence Lee <hone02@gmail.com>2013-03-07 10:19:37 -0800
committerTerence Lee <hone02@gmail.com>2013-03-07 10:19:37 -0800
commit4488c5db74a0936d8a419623543e76d6c37b65bf (patch)
tree02ad08a8e2efd0cc712d70f4d8bd0299c6aba73e
parent253c299b00d4b059c381eae2522ce058e691befb (diff)
downloadbundler-4488c5db74a0936d8a419623543e76d6c37b65bf.tar.gz
don't store dry-run as a setting
-rw-r--r--lib/bundler/cli.rb3
-rw-r--r--lib/bundler/runtime.rb8
-rw-r--r--spec/other/clean_spec.rb30
3 files changed, 35 insertions, 6 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 2544641f64..15783c0a05 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -733,8 +733,7 @@ module Bundler
"forces clean even if --path is not set"
def clean
if Bundler.settings[:path] || options[:force]
- Bundler.settings[:dry_run] = options[:"dry-run"]
- Bundler.load.clean
+ Bundler.load.clean(options[:"dry-run"])
else
Bundler.ui.error "Can only use bundle clean when --path is set or --force is set"
exit 1
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index 6ae2f1cdc8..84ee6fc05e 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -124,7 +124,7 @@ module Bundler
prune_git_and_path_cache(resolve)
end
- def clean
+ def clean(dry_run = false)
gem_bins = Dir["#{Gem.dir}/bin/*"]
git_dirs = Dir["#{Gem.dir}/bundler/gems/*"]
git_cache_dirs = Dir["#{Gem.dir}/cache/bundler/git/*"]
@@ -169,7 +169,7 @@ module Bundler
version = parts.last
output = "#{name} (#{version})"
- if Bundler.settings[:dry_run]
+ if dry_run
Bundler.ui.info "Would have removed #{output}"
else
Bundler.ui.info "Removing #{output}"
@@ -185,7 +185,7 @@ module Bundler
revision = parts[-1]
output = "#{name} (#{revision})"
- if Bundler.settings[:dry_run]
+ if dry_run
Bundler.ui.info "Would have removed #{output}"
else
Bundler.ui.info "Removing #{output}"
@@ -195,7 +195,7 @@ module Bundler
output
end
- unless Bundler.settings[:dry_run]
+ unless dry_run
stale_gem_bins.each { |bin| FileUtils.rm(bin) if File.exists?(bin) }
stale_gem_files.each { |file| FileUtils.rm(file) if File.exists?(file) }
stale_gemspec_files.each { |file| FileUtils.rm(file) if File.exists?(file) }
diff --git a/spec/other/clean_spec.rb b/spec/other/clean_spec.rb
index 6c8328502f..393902ba08 100644
--- a/spec/other/clean_spec.rb
+++ b/spec/other/clean_spec.rb
@@ -559,4 +559,34 @@ describe "bundle clean" do
expect(vendored_gems("bin/rackup")).to exist
end
+
+ it "doesn't store dry run as a config setting" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "thin"
+ gem "foo"
+ G
+
+ bundle "install --path vendor/bundle --no-clean"
+ bundle "config dry_run false"
+
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "thin"
+ G
+
+ bundle :install
+
+ bundle "clean"
+
+ expect(out).to eq("Removing foo (1.0)")
+ expect(out).not_to eq("Would have removed foo (1.0)")
+
+ should_have_gems 'thin-1.0', 'rack-1.0.0'
+ should_not_have_gems 'foo-1.0'
+
+ expect(vendored_gems("bin/rackup")).to exist
+ end
end