[rubygems/rubygems] Pick the last founded gems when fetching metadata

https://github.com/rubygems/rubygems/commit/e3d150d822

Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
This commit is contained in:
Daniel Niknam 2021-08-19 19:47:25 +10:00 коммит произвёл Hiroshi SHIBATA
Родитель 54ae3f587e
Коммит c71d1a26ef
2 изменённых файлов: 21 добавлений и 3 удалений

Просмотреть файл

@ -77,11 +77,11 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
newest = found.last
unless @force
found_matching_metadata = found.select do |spec|
found_matching_metadata = found.reverse.find do |spec|
metadata_satisfied?(spec)
end
if found_matching_metadata.empty?
if found_matching_metadata.nil?
if newest
ensure_required_ruby_version_met(newest.spec)
ensure_required_rubygems_version_met(newest.spec)
@ -92,7 +92,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
raise exc
end
else
newest = found_matching_metadata.last
newest = found_matching_metadata
end
end

Просмотреть файл

@ -64,6 +64,24 @@ class TestGemResolverInstallerSet < Gem::TestCase
assert_equal %w[a-1], set.always_install.map {|s| s.full_name }
end
def test_add_always_install_prerelease_github_problem
spec_fetcher do |fetcher|
fetcher.gem 'a', 1
end
# Github has an issue in which it will generate a misleading prerelease output in its RubyGems server API and
# returns a 0 version for the gem while it doesn't exist.
@fetcher.data["#{@gem_repo}prerelease_specs.#{Gem.marshal_version}.gz"] = util_gzip(Marshal.dump([
Gem::NameTuple.new('a', Gem::Version.new(0), 'ruby'),
]))
set = Gem::Resolver::InstallerSet.new :both
set.add_always_install dep('a')
assert_equal %w[a-1], set.always_install.map {|s| s.full_name }
end
def test_add_always_install_prerelease_only
spec_fetcher do |fetcher|
fetcher.gem 'a', '3.a'