Skip to content

Commit

Permalink
Revert "add --clean to bundle install"
Browse files Browse the repository at this point in the history
This reverts commit 626a163.
  • Loading branch information
hone committed Oct 29, 2010
1 parent f480af9 commit ce7373c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 86 deletions.
10 changes: 0 additions & 10 deletions lib/bundler/cli.rb
Expand Up @@ -153,8 +153,6 @@ def check
"Install using defaults tuned for deployment environments"
method_option "production", :type => :boolean, :banner =>
"Deprecated, please use --deployment instead"
method_option "clean", :type => :boolean, :banner =>
"Cleans up unused gems in your bundler directory"
def install(path = nil)
opts = options.dup
opts[:without] ||= []
Expand Down Expand Up @@ -210,10 +208,6 @@ def install(path = nil)
Bundler.settings[:frozen] = '1'
end

if opts[:clean]
Bundler.settings[:clean] = '1'
end

# Can't use Bundler.settings for this because settings needs gemfile.dirname
Bundler.settings[:path] = nil if opts[:system]
Bundler.settings[:path] = "vendor/bundle" if opts[:deployment]
Expand All @@ -227,10 +221,6 @@ def install(path = nil)
Installer.install(Bundler.root, Bundler.definition, opts)
Bundler.load.cache if Bundler.root.join("vendor/cache").exist?

if Bundler.settings[:clean]
clean
end

if Bundler.settings[:path]
relative_path = Bundler.settings[:path]
relative_path = "./" + relative_path unless relative_path[0] == ?/
Expand Down
121 changes: 45 additions & 76 deletions spec/other/clean_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"

shared_examples_for "bundle clean" do
describe "bundle clean" do
it "removes unused gems that are different" do
install_gemfile <<-G
source "file://#{gem_repo1}"
Expand All @@ -17,9 +17,10 @@
gem "thin"
G

bundle_command
bundle :install
bundle :clean

out.should include("Removing foo (1.0)")
out.should == "Removing foo (1.0)"

vendored_gems("gems/thin-1.0").should exist
vendored_gems("gems/rack-1.0.0").should exist
Expand Down Expand Up @@ -49,9 +50,10 @@
gem "foo"
G

bundle_command
bundle :install
bundle :clean

out.should include("Removing rack (0.9.1)")
out.should == "Removing rack (0.9.1)"

vendored_gems("gems/foo-1.0").should exist
vendored_gems("gems/rack-1.0.0").should exist
Expand Down Expand Up @@ -81,9 +83,10 @@
gem "foo"
G

bundle_command
bundle :install
bundle :clean

out.should include("Removing rack (1.0.0)")
out.should == "Removing rack (1.0.0)"

vendored_gems("gems/foo-1.0").should exist
vendored_gems("gems/rack-0.9.1").should exist
Expand All @@ -96,6 +99,32 @@
vendored_gems("bin/rackup").should exist
end

it "remove gems in bundle without groups" do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "foo"
group :test_group do
gem "rack", "1.0.0"
end
G

bundle "install --path vendor"
bundle "install --without test_group"
bundle :clean

out.should == "Removing rack (1.0.0)"

vendored_gems("gems/foo-1.0").should exist
vendored_gems("gems/rack-1.0.0").should_not exist

vendored_gems("specifications/foo-1.0.gemspec").should exist
vendored_gems("specifications/rack-1.0.0.gemspec").should_not exist

vendored_gems("bin/rackup").should_not exist
end

it "removes unused git gems" do
build_git "foo"
@revision = revision_for(lib_path("foo-1.0"))
Expand All @@ -117,9 +146,10 @@
gem "rack", "1.0.0"
G

bundle_command
bundle :install
bundle :clean

out.should include("Removing foo (1.0 #{@revision[0..11]})")
out.should == "Removing foo (1.0 #{@revision[0..11]})"

vendored_gems("gems/rack-1.0.0").should exist
vendored_gems("bundler/gems/foo-1.0-#{@revision[0..11]}").should_not exist
Expand Down Expand Up @@ -148,9 +178,10 @@
revision2 = revision_for(lib_path("foo-1.0"))

bundle :update
bundle_command
bundle :install
bundle :clean

out.should include("Removing foo (1.0 #{revision[0..11]})")
out.should == "Removing foo (1.0 #{revision[0..11]})"

vendored_gems("gems/rack-1.0.0").should exist
vendored_gems("bundler/gems/foo-1.0-#{revision[0..11]}").should_not exist
Expand All @@ -168,71 +199,9 @@
gem "rack", "1.0.0"
G

bundle_command

out.should include("Can only use bundle clean when --path is set")
end
end

share_examples_for "bundle clean without groups" do
it "remove gems in bundle without groups" do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "foo"
group :test_group do
gem "rack", "1.0.0"
end
G

bundle "install --path vendor"
bundle_command

out.should include("Removing rack (1.0.0)")

vendored_gems("gems/foo-1.0").should exist
vendored_gems("gems/rack-1.0.0").should_not exist

vendored_gems("specifications/foo-1.0.gemspec").should exist
vendored_gems("specifications/rack-1.0.0.gemspec").should_not exist

vendored_gems("bin/rackup").should_not exist
end
end

describe "clean" do
describe "bundle clean" do
def bundle_command
bundle :install
bundle :clean
end

it_behaves_like "bundle clean"

context "without groups" do
def bundle_command
bundle "install --without test_group"
bundle :clean
end

it_behaves_like "bundle clean without groups"
end
end

describe "bundle install --clean" do
def bundle_command
bundle "install --clean"
end

it_behaves_like "bundle clean"

context "without groups" do
def bundle_command
bundle "install --clean --without test_group"
end
bundle :install
bundle :clean

it_behaves_like "bundle clean without groups"
end
out.should == "Can only use bundle clean when --path is set"
end
end

0 comments on commit ce7373c

Please sign in to comment.