[rubygems/rubygems] Fix bundle lock --minor --update <dep>
edge case
When the latest allowed minor of `dep` adds a new dependency, that new dependency would be incorrectly resolved to the latest minor of the first major version. https://github.com/rubygems/rubygems/commit/fd50c9d4f3
This commit is contained in:
parent
705bd6439d
commit
57c3e45ee8
@ -101,7 +101,7 @@ module Bundler
|
|||||||
next 1 if b_pre && !a_pre
|
next 1 if b_pre && !a_pre
|
||||||
end
|
end
|
||||||
|
|
||||||
if major?
|
if major? || locked_version.nil?
|
||||||
a <=> b
|
a <=> b
|
||||||
elsif either_version_older_than_locked?(a, b, locked_version)
|
elsif either_version_older_than_locked?(a, b, locked_version)
|
||||||
a <=> b
|
a <=> b
|
||||||
@ -117,7 +117,7 @@ module Bundler
|
|||||||
end
|
end
|
||||||
|
|
||||||
def either_version_older_than_locked?(a, b, locked_version)
|
def either_version_older_than_locked?(a, b, locked_version)
|
||||||
locked_version && (a.version < locked_version || b.version < locked_version)
|
a.version < locked_version || b.version < locked_version
|
||||||
end
|
end
|
||||||
|
|
||||||
def segments_do_not_match?(a, b, level)
|
def segments_do_not_match?(a, b, level)
|
||||||
|
@ -289,6 +289,47 @@ RSpec.describe "bundle lock" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "conservative updates when minor update adds a new dependency" do
|
||||||
|
before do
|
||||||
|
build_repo4 do
|
||||||
|
build_gem "sequel", "5.71.0"
|
||||||
|
build_gem "sequel", "5.72.0" do |s|
|
||||||
|
s.add_dependency "bigdecimal", ">= 0"
|
||||||
|
end
|
||||||
|
build_gem "bigdecimal", %w[1.4.4 3.1.4]
|
||||||
|
end
|
||||||
|
|
||||||
|
gemfile <<~G
|
||||||
|
source "#{file_uri_for(gem_repo4)}"
|
||||||
|
gem 'sequel'
|
||||||
|
G
|
||||||
|
|
||||||
|
lockfile <<~L
|
||||||
|
GEM
|
||||||
|
remote: #{file_uri_for(gem_repo4)}/
|
||||||
|
specs:
|
||||||
|
sequel (5.71.0)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
ruby
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
sequel
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
#{Bundler::VERSION}
|
||||||
|
L
|
||||||
|
|
||||||
|
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "adds the latest version of the new dependency" do
|
||||||
|
bundle "lock --minor --update sequel"
|
||||||
|
|
||||||
|
expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[sequel-5.72.0 bigdecimal-3.1.4].sort)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "updates the bundler version in the lockfile to the latest bundler version" do
|
it "updates the bundler version in the lockfile to the latest bundler version" do
|
||||||
build_repo4 do
|
build_repo4 do
|
||||||
build_gem "bundler", "55"
|
build_gem "bundler", "55"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user