summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Thacker-Smith <Dylan.Smith@shopify.com>2019-03-21 12:27:41 -0400
committerDylan Thacker-Smith <Dylan.Smith@shopify.com>2019-03-21 12:27:51 -0400
commita5d5feec2a170ede658df9323c15c0408aa754fb (patch)
tree17ef24c59d3a95089098c804e76521f5a5fbae80
parentb7de89fa8c1e39251051d26298a902c2630b2e2b (diff)
downloadbundler-a5d5feec2a170ede658df9323c15c0408aa754fb.tar.gz
Make `bundle clean` clean git extension directories
-rw-r--r--lib/bundler/runtime.rb2
-rw-r--r--spec/commands/clean_spec.rb39
2 files changed, 40 insertions, 1 deletions
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index 762e7b3ec6..83945868f9 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -163,7 +163,7 @@ module Bundler
gem_dirs = Dir["#{Gem.dir}/gems/*"]
gem_files = Dir["#{Gem.dir}/cache/*.gem"]
gemspec_files = Dir["#{Gem.dir}/specifications/*.gemspec"]
- extension_dirs = Dir["#{Gem.dir}/extensions/*/*/*"]
+ extension_dirs = Dir["#{Gem.dir}/extensions/*/*/*"] + Dir["#{Gem.dir}/bundler/gems/extensions/*/*/*"]
spec_gem_paths = []
# need to keep git sources around
spec_git_paths = @definition.spec_git_paths
diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb
index 6cd796f694..96599a965b 100644
--- a/spec/commands/clean_spec.rb
+++ b/spec/commands/clean_spec.rb
@@ -770,4 +770,43 @@ RSpec.describe "bundle clean" do
expect(very_simple_binary_extensions_dir).not_to exist
expect(simple_binary_extensions_dir).to exist
end
+
+ it "removes git extension directories", :ruby_repo do
+ build_git "very_simple_git_binary", &:add_c_extension
+
+ revision = revision_for(lib_path("very_simple_git_binary-1.0"))
+ short_revision = revision[0..11]
+
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "thin"
+ gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
+ G
+
+ bundle! "install", forgotten_command_line_options(:path => "vendor/bundle")
+
+ very_simple_binary_extensions_dir =
+ Pathname.glob("#{vendored_gems}/bundler/gems/extensions/*/*/very_simple_git_binary-1.0-#{short_revision}").first
+
+ expect(very_simple_binary_extensions_dir).to exist
+
+ gemfile <<-G
+ gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
+ G
+
+ bundle! "install"
+ bundle! :clean
+ expect(out).to include("Removing thin (1.0)")
+ expect(very_simple_binary_extensions_dir).to exist
+
+ gemfile <<-G
+ G
+
+ bundle! "install"
+ bundle! :clean
+ expect(out).to eq("Removing very_simple_git_binary-1.0 (#{short_revision})")
+
+ expect(very_simple_binary_extensions_dir).not_to exist
+ end
end