diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-08 01:32:18 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-08 01:32:18 +0000 |
commit | c00e84327f14845bd484e76b5ee5dfeb1fa9ce3d (patch) | |
tree | 9f558dafa363f4f0118d504a50cd4461e2821cd1 /lib/rubygems/source | |
parent | 6b05153a3a75b74b64553d6a46f501d9ee0f0376 (diff) |
Merge rubygems master.
This is RC version of Rubygems 2.7.0.
https://github.com/rubygems/rubygems/commit/688fb7e83c13c3fe7c2bb03c49a2db4c82852aee
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/source')
-rw-r--r-- | lib/rubygems/source/git.rb | 3 | ||||
-rw-r--r-- | lib/rubygems/source/local.rb | 73 | ||||
-rw-r--r-- | lib/rubygems/source/lock.rb | 5 |
3 files changed, 44 insertions, 37 deletions
diff --git a/lib/rubygems/source/git.rb b/lib/rubygems/source/git.rb index 0900da0cbc..23f8928a4e 100644 --- a/lib/rubygems/source/git.rb +++ b/lib/rubygems/source/git.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require 'digest' require 'rubygems/util' ## @@ -226,6 +225,8 @@ class Gem::Source::Git < Gem::Source # A hash for the git gem based on the git repository URI. def uri_hash # :nodoc: + require 'digest' # required here to avoid deadlocking in Gem.activate_bin_path (because digest is a gem on 2.5+) + normalized = if @repository =~ %r%^\w+://(\w+@)?% then uri = URI(@repository).normalize.to_s.sub %r%/$%,'' diff --git a/lib/rubygems/source/local.rb b/lib/rubygems/source/local.rb index 3227fb61b0..5ab7a467b5 100644 --- a/lib/rubygems/source/local.rb +++ b/lib/rubygems/source/local.rb @@ -9,6 +9,7 @@ class Gem::Source::Local < Gem::Source @specs = nil @api_uri = nil @uri = nil + @load_specs_names = {} end ## @@ -34,45 +35,47 @@ class Gem::Source::Local < Gem::Source end def load_specs type # :nodoc: - names = [] - - @specs = {} - - Dir["*.gem"].each do |file| - begin - pkg = Gem::Package.new(file) - rescue SystemCallError, Gem::Package::FormatError - # ignore - else - tup = pkg.spec.name_tuple - @specs[tup] = [File.expand_path(file), pkg] - - case type - when :released - unless pkg.spec.version.prerelease? - names << pkg.spec.name_tuple - end - when :prerelease - if pkg.spec.version.prerelease? - names << pkg.spec.name_tuple - end - when :latest - tup = pkg.spec.name_tuple + @load_specs_names[type] ||= begin + names = [] - cur = names.find { |x| x.name == tup.name } - if !cur - names << tup - elsif cur.version < tup.version - names.delete cur - names << tup - end + @specs = {} + + Dir["*.gem"].each do |file| + begin + pkg = Gem::Package.new(file) + rescue SystemCallError, Gem::Package::FormatError + # ignore else - names << pkg.spec.name_tuple + tup = pkg.spec.name_tuple + @specs[tup] = [File.expand_path(file), pkg] + + case type + when :released + unless pkg.spec.version.prerelease? + names << pkg.spec.name_tuple + end + when :prerelease + if pkg.spec.version.prerelease? + names << pkg.spec.name_tuple + end + when :latest + tup = pkg.spec.name_tuple + + cur = names.find { |x| x.name == tup.name } + if !cur + names << tup + elsif cur.version < tup.version + names.delete cur + names << tup + end + else + names << pkg.spec.name_tuple + end end end - end - names + names + end end def find_gem gem_name, version = Gem::Requirement.default, # :nodoc: @@ -88,7 +91,7 @@ class Gem::Source::Local < Gem::Source if version.satisfied_by?(s.version) if prerelease found << s - elsif !s.version.prerelease? + elsif !s.version.prerelease? || version.prerelease? found << s end end diff --git a/lib/rubygems/source/lock.rb b/lib/rubygems/source/lock.rb index 86b16e964c..59717be2c0 100644 --- a/lib/rubygems/source/lock.rb +++ b/lib/rubygems/source/lock.rb @@ -34,6 +34,10 @@ class Gem::Source::Lock < Gem::Source 0 == (self <=> other) end + def hash # :nodoc: + @wrapped.hash ^ 3 + end + ## # Delegates to the wrapped source's fetch_spec method. @@ -46,4 +50,3 @@ class Gem::Source::Lock < Gem::Source end end - |