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

Commit

Permalink
Make bundle clean clean git extension directories
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanahsmith committed Mar 21, 2019
1 parent b7de89f commit a5d5fee
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 a5d5fee

Please sign in to comment.