Skip to content

Commit

Permalink
Backport the fix to bundler to work with older versions of rubygems
Browse files Browse the repository at this point in the history
  • Loading branch information
toy committed Sep 5, 2020
1 parent 53c9377 commit c33914f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions bundler/lib/bundler/rubygems_ext.rb
Expand Up @@ -129,6 +129,34 @@ def to_lock
end
end

unless Gem::Requirement.new("> 1", "< 2") == Gem::Requirement.new("< 2", "> 1")
class Requirement
module OrderIndependentComparison
def ==(other)
if _requirements_sorted? && other._requirements_sorted?
super
else
_with_sorted_requirements == other._with_sorted_requirements
end
end

protected

def _requirements_sorted?
return @_are_requirements_sorted if defined?(@_are_requirements_sorted)
strings = as_list
@_are_requirements_sorted = strings == strings.sort
end

def _with_sorted_requirements
@_with_sorted_requirements ||= _requirements_sorted? ? self : self.class.new(as_list.sort)
end
end

prepend OrderIndependentComparison
end
end

class Platform
JAVA = Gem::Platform.new("java") unless defined?(JAVA)
MSWIN = Gem::Platform.new("mswin32") unless defined?(MSWIN)
Expand Down
2 changes: 1 addition & 1 deletion bundler/spec/install/gemfile/platform_spec.rb
Expand Up @@ -256,7 +256,7 @@
expect(the_bundle).not_to include_gem "CFPropertyList"
end

it "works with gems with platform-specific dependency having different requirements order", :rubygems => ">= 3.2.0.rc.2" do
it "works with gems with platform-specific dependency having different requirements order" do
simulate_platform x64_mac

update_repo2 do
Expand Down

0 comments on commit c33914f

Please sign in to comment.