diff options
author | The Bundler Bot <bot@bundler.io> | 2017-04-07 00:39:18 +0000 |
---|---|---|
committer | The Bundler Bot <bot@bundler.io> | 2017-04-07 00:39:18 +0000 |
commit | 7358d857d32ce07c79b874e60441b971ff4c0f24 (patch) | |
tree | ec461d521603cf8650413f8603175c3df1bc35e8 | |
parent | 456b34b828130733b144052e485e25feed5dce50 (diff) | |
parent | 72af8a41bc5e7b1ce0402aa156ec527670d778da (diff) | |
download | bundler-7358d857d32ce07c79b874e60441b971ff4c0f24.tar.gz |
Auto merge of #5564 - bundler:seg-load-gempspec-chdir, r=indirect
[Bundler] Avoid chdir when loading a yaml gemspec
-rw-r--r-- | lib/bundler.rb | 22 | ||||
-rw-r--r-- | lib/bundler/definition.rb | 13 |
2 files changed, 19 insertions, 16 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index 1969f36a71..88822f8f1a 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -413,20 +413,20 @@ EOF def load_gemspec_uncached(file, validate = false) path = Pathname.new(file) - # Eval the gemspec from its parent directory, because some gemspecs - # depend on "./" relative paths. - SharedHelpers.chdir(path.dirname.to_s) do - contents = path.read - spec = if contents[0..2] == "---" # YAML header - eval_yaml_gemspec(path, contents) - else + contents = path.read + spec = if contents.start_with?("---") # YAML header + eval_yaml_gemspec(path, contents) + else + # Eval the gemspec from its parent directory, because some gemspecs + # depend on "./" relative paths. + SharedHelpers.chdir(path.dirname.to_s) do eval_gemspec(path, contents) end - return unless spec - spec.loaded_from = path.expand_path.to_s - Bundler.rubygems.validate(spec) if validate - spec end + return unless spec + spec.loaded_from = path.expand_path.to_s + Bundler.rubygems.validate(spec) if validate + spec end def clear_gemspec_cache diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index e31de3d38a..5dca425c7e 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -746,11 +746,13 @@ module Bundler # Don't add a spec to the list if its source is expired. For example, # if you change a Git gem to Rubygems. - next if s.source.nil? || @unlock[:sources].include?(s.source.name) + next if s.source.nil? + next if @unlock[:sources].include?(s.source.name) # XXX This is a backwards-compatibility fix to preserve the ability to # unlock a single gem by passing its name via `--source`. See issue #3759 - next if s.source.nil? || @unlock[:sources].include?(s.name) + # TODO: delete in Bundler 2 + next if @unlock[:sources].include?(s.name) # If the spec is from a path source and it doesn't exist anymore # then we unlock it. @@ -774,14 +776,15 @@ module Bundler resolve = SpecSet.new(converged) resolve = resolve.for(expand_dependencies(deps, true), @unlock[:gems]) - diff = @locked_specs.to_a - resolve.to_a + diff = nil # Now, we unlock any sources that do not have anymore gems pinned to it sources.all_sources.each do |source| next unless source.respond_to?(:unlock!) unless resolve.any? {|s| s.source == source } - source.unlock! if !diff.empty? && diff.any? {|s| s.source == source } + diff ||= @locked_specs.to_a - resolve.to_a + source.unlock! if diff.any? {|s| s.source == source } end end @@ -796,7 +799,7 @@ module Bundler end def satisfies_locked_spec?(dep) - @locked_specs.any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) } + @locked_specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) } end # This list of dependencies is only used in #resolve, so it's OK to add |