Permalink
Browse files

#1490. Check for 7 char length git revision for bundle clean

  • Loading branch information...
1 parent afc2ff6 commit 35eee2b421066c234c4fba8904681e2685a9c3bb @hone hone committed Oct 21, 2011
Showing with 31 additions and 1 deletion.
  1. +1 −1 lib/bundler/runtime.rb
  2. +30 −0 spec/other/clean_spec.rb
View
@@ -146,7 +146,7 @@ def clean
specs.each do |spec|
spec_gem_paths << spec.full_gem_path
# need to check here in case gems are nested like for the rails git repo
- md = %r{(.+bundler/gems/.+-[a-f0-9]{12})}.match(spec.full_gem_path)
+ md = %r{(.+bundler/gems/.+-[a-f0-9]{7,12})}.match(spec.full_gem_path)
spec_git_paths << md[1] if md
spec_gem_executables << spec.executables.collect do |executable|
"#{Gem.dir}/#{spec.bindir}/#{executable}"
View
@@ -394,4 +394,34 @@ def should_not_have_gems(*gems)
out.should_not include("foo (1.0)")
out.should include("rack (1.0.0)")
end
+
+ it "cleans git gems with a 7 length git revision" do
+ build_git "foo"
+ revision = revision_for(lib_path("foo-1.0"))
+
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
+ G
+
+ bundle "install --path vendor/bundle --no-clean"
+
+ # mimic 7 length git revisions in Gemfile.lock
+ gemfile_lock = File.read(bundled_app('Gemfile.lock')).split("\n")
+ gemfile_lock.each_with_index do |line, index|
+ gemfile_lock[index] = line[0..(11 + 7)] if line.include?(" revision:")
+ end
+ File.open(bundled_app('Gemfile.lock'), 'w') do |file|
+ file.print gemfile_lock.join("\n")
+ end
+
+ bundle "install --path vendor/bundle --no-clean"
+
+ bundle :clean
+
+ out.should_not include("Removing foo (1.0 #{revision[0..6]})")
+
+ vendored_gems("bundler/gems/foo-1.0-#{revision[0..6]}").should exist
+ end
end

0 comments on commit 35eee2b

Please sign in to comment.