summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-03-27 06:19:13 +0000
committerBundlerbot <bot@bundler.io>2019-03-27 06:19:13 +0000
commit2364c12b1798627bf80e8a04ec2e0aeba84d266e (patch)
tree590cb5ccb4bf4962bc9d752e63d6b3d97ba826ff
parentdf8b92fa42efec18b0bd9cffa9dc6a6c7e99ee1c (diff)
parenta5d5feec2a170ede658df9323c15c0408aa754fb (diff)
downloadbundler-2364c12b1798627bf80e8a04ec2e0aeba84d266e.tar.gz
Merge #7059
7059: Make `bundle clean` clean git extension directories r=hsbt a=dylanahsmith Fixes #7058 This PR fixes it by adding the native extension directories for git gems to the ones for non-git gems. This is used to get the unused extension directories (`stale_extension_dirs = extension_dirs - spec_extension_paths`) which was already excluding extension directories for git gems. Co-authored-by: Dylan Thacker-Smith <dylan.smith@shopify.com>
-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