Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Merge #7059
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bundlerbot and dylanahsmith committed Mar 27, 2019
2 parents df8b92f + a5d5fee commit 2364c12
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bundler/runtime.rb
Expand Up @@ -163,7 +163,7 @@ def clean(dry_run = false)
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
Expand Down
39 changes: 39 additions & 0 deletions spec/commands/clean_spec.rb
Expand Up @@ -770,4 +770,43 @@ def should_not_have_gems(*gems)
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

0 comments on commit 2364c12

Please sign in to comment.