Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 1 addition & 39 deletions python/lib/dependabot/python/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def inspect # :nodoc:
end

def <=>(other)
version_comparison = old_comp(other)
version_comparison = super(other)
return version_comparison unless version_comparison.zero?

return post_version_comparison(other) unless post_version_comparison(other).zero?
Expand Down Expand Up @@ -108,44 +108,6 @@ def normalise_prerelease(version)
tr("-", ".").
gsub(/(\d)([a-z])/i, '\1.\2')
end

# TODO: Delete this once we're using a version of Rubygems that includes
# https://github.com/rubygems/rubygems/pull/2651
#
# rubocop:disable Metrics/PerceivedComplexity
# rubocop:disable Style/CaseEquality
# rubocop:disable Style/ParallelAssignment
# rubocop:disable Style/RedundantReturn
def old_comp(other)
return unless Gem::Version === other
return 0 if @version == other._version || canonical_segments == other.canonical_segments

lhsegments = canonical_segments
rhsegments = other.canonical_segments

lhsize = lhsegments.size
rhsize = rhsegments.size
limit = (lhsize > rhsize ? lhsize : rhsize) - 1

i = 0

while i <= limit
lhs, rhs = lhsegments[i] || 0, rhsegments[i] || 0
i += 1

next if lhs == rhs
return -1 if String === lhs && Numeric === rhs
return 1 if Numeric === lhs && String === rhs

return lhs <=> rhs
end

return 0
end
# rubocop:enable Metrics/PerceivedComplexity
# rubocop:enable Style/CaseEquality
# rubocop:enable Style/ParallelAssignment
# rubocop:enable Style/RedundantReturn
end
end
end
Expand Down