[rubygems/rubygems] Don't re-resolve with prereleases if unlocked gem has no prereleases

https://github.com/rubygems/rubygems/commit/d76dc70d90
This commit is contained in:
David Rodriguez 2023-09-30 21:42:39 +02:00 committed by git
parent b73ef92998
commit ed0661e618
3 changed files with 11 additions and 2 deletions

View File

@ -131,7 +131,7 @@ module Bundler
if base_requirements[name]
names_to_unlock << name
elsif package.ignores_prereleases?
elsif package.ignores_prereleases? && @all_specs[name].any? {|s| s.version.prerelease? }
names_to_allow_prereleases_for << name
end

View File

@ -323,7 +323,7 @@ RSpec.describe "real world edgecases", :realworld => true do
if Bundler.feature_flag.bundler_3_mode?
# Conflicts on bundler version, so we count attempts differently
bundle :lock, :env => { "DEBUG_RESOLVER" => "1" }, :raise_on_error => false
expect(out.split("\n").grep(/backtracking to/).count).to eq(16)
expect(out.split("\n").grep(/backtracking to/).count).to eq(8)
else
bundle :lock, :env => { "DEBUG_RESOLVER" => "1" }
expect(out).to include("Solution found after 7 attempts")

View File

@ -107,6 +107,15 @@ RSpec.describe "Resolving" do
end.to raise_error(Bundler::SolveFailure)
end
it "does not try to re-resolve including prereleases if gems involved don't have prereleases" do
@index = a_unresolvable_child_index
dep "chef_app_error"
expect(Bundler.ui).not_to receive(:debug).with("Retrying resolution...", any_args)
expect do
resolve
end.to raise_error(Bundler::SolveFailure)
end
it "raises an exception with the minimal set of conflicting dependencies" do
@index = build_index do
%w[0.9 1.0 2.0].each {|v| gem("a", v) }