Skip to content

Commit

Permalink
Merge pull request #754 from sagiwei/master
Browse files Browse the repository at this point in the history
Fix semantic version comparison for mixed numeric and string prerelease segments
  • Loading branch information
amorde authored Jul 27, 2024
2 parents ffea754 + 713397c commit 6cd7867
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/cocoapods-core/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ def compare_segments(other)

if comparison = lhs <=> rhs
return comparison
else
return -1 if lhs.is_a?(Numeric) && rhs.is_a?(String)
return 1 if rhs.is_a?(Numeric) && lhs.is_a?(String)
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions spec/version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ module Pod

# Example from CocoaPods/CocoaPods#5718
Version.new('1.0-beta.8').should.be < Version.new('1.0-beta.8a')

# Example from section 11.4.3 on semver.org
Version.new('1.0.0-beta.3rd.1').should.not.be >= Version.new('1.0.0-beta.ios17.1')
end
end

Expand Down

0 comments on commit 6cd7867

Please sign in to comment.