summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTerence Lee <hone02@gmail.com>2012-09-14 10:41:42 +0900
committerTerence Lee <hone02@gmail.com>2012-09-14 10:41:42 +0900
commit9afd8849f50957a06f10498caa556d076a55f680 (patch)
tree90695a93d9181c824d0a8f9c667264a596f2c6ae
parent7dd2ad05eb685ebf73b3de2cf4316fcddc5ad0b6 (diff)
downloadbundler-9afd8849f50957a06f10498caa556d076a55f680.tar.gz
Revert "`clean` should not remove gems in the lockfile"
This reverts commit aefa530cdc7b209bc646e98b7a730078d064665f. bundle clean should remove BUNDLE_WITHOUT gems. BUNDLE_WITHOUT settings should be standardized across commands as well if you are using BUNDLE_WITHOUT you probably don't want the gems to be around when cleaning.
-rw-r--r--lib/bundler/definition.rb8
-rw-r--r--lib/bundler/runtime.rb4
-rw-r--r--spec/other/clean_spec.rb25
3 files changed, 28 insertions, 9 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 151ce2bb50..98508a60ac 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -108,9 +108,9 @@ module Bundler
specs
end
- def specs(deps = requested_dependencies)
+ def specs
@specs ||= begin
- specs = resolve.materialize(deps)
+ specs = resolve.materialize(requested_dependencies)
unless specs["bundler"].any?
local = Bundler.settings[:frozen] ? rubygems_index : index
@@ -130,10 +130,6 @@ module Bundler
@locked_specs - specs
end
- def all_specs
- specs(dependencies)
- end
-
def new_platform?
@new_platform
end
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index 5d7101b2e3..db6f21d698 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -123,12 +123,12 @@ module Bundler
gemspec_files = Dir["#{Gem.dir}/specifications/*.gemspec"]
spec_gem_paths = []
# need to keep git sources around
- spec_git_paths = []
+ spec_git_paths = @definition.sources.select {|s| s.is_a?(Bundler::Source::Git) }.map {|s| s.path.to_s }
spec_git_cache_dirs = []
spec_gem_executables = []
spec_cache_paths = []
spec_gemspec_paths = []
- @definition.all_specs.each do |spec|
+ specs.each do |spec|
spec_gem_paths << spec.full_gem_path
# need to check here in case gems are nested like for the rails git repo
md = %r{(.+bundler/gems/.+-[a-f0-9]{7,12})}.match(spec.full_gem_path)
diff --git a/spec/other/clean_spec.rb b/spec/other/clean_spec.rb
index fc8bd7781a..35a5339c53 100644
--- a/spec/other/clean_spec.rb
+++ b/spec/other/clean_spec.rb
@@ -100,6 +100,29 @@ describe "bundle clean" do
vendored_gems("bin/rackup").should exist
end
+ it "remove gems in bundle without groups" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "foo"
+
+ group :test_group do
+ gem "rack", "1.0.0"
+ end
+ G
+
+ bundle "install --path vendor/bundle"
+ bundle "install --without test_group"
+ bundle :clean
+
+ out.should eq("Removing rack (1.0.0)")
+
+ should_have_gems 'foo-1.0'
+ should_not_have_gems 'rack-1.0.0'
+
+ vendored_gems("bin/rackup").should_not exist
+ end
+
it "does not remove cached git dir if it's being used" do
build_git "foo"
revision = revision_for(lib_path("foo-1.0"))
@@ -231,7 +254,7 @@ describe "bundle clean" do
out.should eq("")
vendored_gems("bundler/gems/foo-#{revision[0..11]}").should exist
digest = Digest::SHA1.hexdigest(git_path.to_s)
- vendored_gems("cache/bundler/git/foo-#{digest}").should exist
+ vendored_gems("cache/bundler/git/foo-#{digest}").should_not exist
end
it "does not blow up when using without groups" do