Skip to content

Commit

Permalink
rubygems#1490. Check for 7 char length git revision for bundle clean
Browse files Browse the repository at this point in the history
  • Loading branch information
hone committed Oct 21, 2011
1 parent afc2ff6 commit 35eee2b
Show file tree
Hide file tree
Showing 2 changed files with 31 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 @@ -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}"
Expand Down
30 changes: 30 additions & 0 deletions spec/other/clean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.