Permalink
Browse files

cache command no longer prunes gems built with older rubygems versions

  • Loading branch information...
indirect committed Apr 21, 2010
1 parent a5ecbe1 commit 7c9e331d83f48a3b1a8a22aeec5471da613f50a3
Showing with 22 additions and 2 deletions.
  1. +3 −2 lib/bundler/cli.rb
  2. +11 −0 spec/cache/gems_spec.rb
  3. +8 −0 spec/support/builders.rb
View
@@ -72,6 +72,7 @@ def check
method_option "relock", :type => :boolean, :banner => "Unlock, install the gems, and relock."
method_option "disable-shared-gems", :type => :boolean, :banner => "Do not use any shared gems, such as the system gem repository."
method_option "gemfile", :type => :string, :banner => "Use the specified gemfile instead of Gemfile"
+ method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
def install(path = nil)
opts = options.dup
opts[:without] ||= []
@@ -91,11 +92,11 @@ def install(path = nil)
raise GemfileChanged, "You changed your Gemfile after locking. " +
"Please run `bundle install --relock`."
end
- Bundler.ui.confirm "Your bundle is complete! " +
- "Use `bundle show [gemname]` to see where a bundled gem is installed."
lock if options[:relock]
cache if Bundler.root.join("vendor/cache").exist?
+ Bundler.ui.confirm "Your bundle is complete! " +
+ "Use `bundle show [gemname]` to see where a bundled gem is installed."
rescue GemNotFound => e
if Bundler.definition.sources.empty?
Bundler.ui.warn "Your Gemfile doesn't have any sources. You can add one with a line like 'source :gemcutter'"
View
@@ -115,6 +115,17 @@
cached_gem("actionpack-2.3.2").should_not exist
cached_gem("activesupport-2.3.2").should_not exist
end
+
+ it "doesn't remove gems with mismatched :rubygems_version or :date" do
+ cached_gem("rack-1.0.0").rmtree
+ build_gem "rack", "1.0.0",
+ :path => bundled_app('vendor/cache'),
+ :rubygems_version => "1.3.2"
+ simulate_new_machine
+
+ bundle :install
+ cached_gem("rack-1.0.0").should exist
+ end
end
end
View
@@ -369,6 +369,13 @@ def add_c_extension
def _build(options)
path = options[:path] || _default_path
+
+ if options[:rubygems_version]
+ @spec.rubygems_version = options[:rubygems_version]
+ def @spec.mark_version; end
+ def @spec.validate; end
+ end
+
case options[:gemspec]
when false
# do nothing
@@ -381,6 +388,7 @@ def _build(options)
unless options[:no_default]
@files = _default_files.merge(@files)
end
+
@files.each do |file, source|
file = Pathname.new(path).join(file)
FileUtils.mkdir_p(file.dirname)

0 comments on commit 7c9e331

Please sign in to comment.