Skip to content

Commit

Permalink
Fix crash in pub grub involving empty ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Feb 13, 2023
1 parent b9331b8 commit 0f16851
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def empty?
true
end

def eql?
def eql?(other)
other.empty?
end

Expand Down
56 changes: 56 additions & 0 deletions bundler/spec/commands/lock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,62 @@ def read_lockfile(file = "Gemfile.lock")
bundle "lock --add-platform x86_64-linux", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
end

it "does not crash on conflicting ruby requirements between platform versions in two different gems" do
build_repo4 do
build_gem "unf_ext", "0.0.8.2"

build_gem "unf_ext", "0.0.8.2" do |s|
s.required_ruby_version = [">= 2.4", "< #{previous_ruby_minor}"]
s.platform = "x64-mingw32"
end

build_gem "unf_ext", "0.0.8.2" do |s|
s.required_ruby_version = [">= #{previous_ruby_minor}", "< #{current_ruby_minor}"]
s.platform = "x64-mingw-ucrt"
end

build_gem "google-protobuf", "3.21.12"

build_gem "google-protobuf", "3.21.12" do |s|
s.required_ruby_version = [">= 2.5", "< #{previous_ruby_minor}"]
s.platform = "x64-mingw32"
end

build_gem "google-protobuf", "3.21.12" do |s|
s.required_ruby_version = [">= #{previous_ruby_minor}", "< #{current_ruby_minor}"]
s.platform = "x64-mingw-ucrt"
end
end

gemfile <<~G
source "https://gem.repo4"
gem "google-protobuf"
gem "unf_ext"
G

lockfile <<~L
GEM
remote: https://gem.repo4/
specs:
google-protobuf (3.21.12)
unf_ext (0.0.8.2)
PLATFORMS
x64-mingw-ucrt
x64-mingw32
DEPENDENCIES
google-protobuf
unf_ext
BUNDLED WITH
#{Bundler::VERSION}
L

bundle "install --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s, "DEBUG_RESOLVER" => "1" }
end

it "respects lower bound ruby requirements" do
build_repo4 do
build_gem "our_private_gem", "0.1.0" do |s|
Expand Down
12 changes: 11 additions & 1 deletion bundler/spec/support/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,17 @@ def current_ruby_minor
end

def next_ruby_minor
Gem.ruby_version.segments[0..1].map.with_index {|s, i| i == 1 ? s + 1 : s }.join(".")
ruby_major_minor.map.with_index {|s, i| i == 1 ? s + 1 : s }.join(".")
end

def previous_ruby_minor
return "2.7" if ruby_major_minor == [3, 0]

ruby_major_minor.map.with_index {|s, i| i == 1 ? s - 1 : s }.join(".")
end

def ruby_major_minor
Gem.ruby_version.segments[0..1]
end

# versions not including
Expand Down

0 comments on commit 0f16851

Please sign in to comment.