diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-03-29 18:36:00 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-03-29 18:43:09 -0500 |
commit | f2c31cd2ea00cd0771cc425da3a18e4226a4c07e (patch) | |
tree | 036c57edf65d0d921fa41a28a12ed7feb454d9ac | |
parent | 755e1a49f29ecc87dbf619310326cc1057adf697 (diff) | |
download | bundler-f2c31cd2ea00cd0771cc425da3a18e4226a4c07e.tar.gz |
[Installer] Don't eval gemfile twice
-rw-r--r-- | lib/bundler/definition.rb | 34 | ||||
-rw-r--r-- | lib/bundler/installer.rb | 12 | ||||
-rw-r--r-- | spec/install/gemfile/platform_spec.rb | 4 |
3 files changed, 31 insertions, 19 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 0ee27b3ae7..2298ea4b28 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -46,14 +46,16 @@ module Bundler def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = []) @unlocking = unlock == true || !unlock.empty? - @dependencies = dependencies - @sources = sources - @unlock = unlock - @optional_groups = optional_groups - @remote = false - @specs = nil - @ruby_version = ruby_version - + @dependencies = dependencies + @sources = sources + @original_sources = sources.dup + @unlock = unlock + @optional_groups = optional_groups + @remote = false + @specs = nil + @ruby_version = ruby_version + + @lockfile = lockfile @lockfile_contents = String.new @locked_bundler_version = nil @locked_ruby_version = nil @@ -101,6 +103,18 @@ module Bundler fixup_dependency_types! end + # Returns a copy of the definition with the given set of gems requested to + # be updated. + # + # @param unlock [Hash, Boolean, nil] Gems that have been requested + # to be updated or true if all gems should be updated + # @return [Bundler::Definition] + def with_unlock(unlock = {}) + unlock ||= {} + self.class.new(@lockfile, @dependencies, @original_sources, unlock, + @ruby_version, @optional_groups) + end + def fixup_dependency_types! # XXX This is a temporary workaround for a bug when using rubygems 1.8.15 # where Gem::Dependency#== matches Gem::Dependency#type. As the lockfile @@ -182,12 +196,12 @@ module Bundler end def current_dependencies - dependencies.reject {|d| !d.should_include? } + dependencies.select(&:should_include?) end def specs_for(groups) deps = dependencies.select {|d| (d.groups & groups).any? } - deps.delete_if {|d| !d.should_include? } + deps.select!(&:should_include?) specs.for(expand_dependencies(deps)) end diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index fcf68928e4..4691daf4bc 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -182,16 +182,14 @@ module Bundler def resolve_if_need(options) if Bundler.default_lockfile.exist? && !options["update"] - local = Bundler.ui.silence do - begin - tmpdef = Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, nil) - true unless tmpdef.new_platform? || tmpdef.missing_dependencies.any? - rescue BundlerError - end + begin + tmpdef = @definition.without_unlock + return unless tmpdef.new_platform? || tmpdef.missing_dependencies.any? + rescue BundlerError + nil end end - return if local options["local"] ? @definition.resolve_with_cache! : @definition.resolve_remotely! end end diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb index a562a3bc11..e825ac4f20 100644 --- a/spec/install/gemfile/platform_spec.rb +++ b/spec/install/gemfile/platform_spec.rb @@ -95,12 +95,12 @@ describe "bundle install across platforms" do gem "rack", "1.0.0" G - bundle "install --path vendor/bundle" + bundle! "install --path vendor/bundle" new_version = Gem::ConfigMap[:ruby_version] == "1.8" ? "1.9.1" : "1.8" FileUtils.mv(vendored_gems, bundled_app("vendor/bundle", Gem.ruby_engine, new_version)) - bundle "install --path vendor/bundle" + bundle! "install --path vendor/bundle" expect(vendored_gems("gems/rack-1.0.0")).to exist end end |