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 4a26833
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions bundler/lib/bundler/rubygems_ext.rb
Expand Up @@ -129,6 +129,33 @@ def to_lock
end
end

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

protected

def _sorted_requirements?
strings = as_list
strings == strings.sort
end

def _with_sorted_requirements
@_with_sorted_requirements ||= 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 4a26833

Please sign in to comment.