Skip to content

Commit

Permalink
fix: add total ordering to Maven version (#2495)
Browse files Browse the repository at this point in the history
Maven `Version` doesn't support `>=`, causing [version
query](https://github.com/google/osv.dev/blob/30d55798022eabb000ecc091f03ec7d5a2002c4a/gcp/api/server.py#L1250)
failures. Add the `total_ordering` function to support all kinds of
ordering.
  • Loading branch information
hogo6002 authored Aug 21, 2024
1 parent 5de0ac2 commit 58fd10d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions osv/ecosystems/maven.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""Maven ecosystem helper."""

import collections
import functools
import re

from .helper_base import DepsDevMixin
Expand Down Expand Up @@ -95,6 +96,7 @@ def __lt__(self, other):
return qualifier_order(self) < qualifier_order(other)


@functools.total_ordering
class Version:
"""Maven version."""

Expand Down
4 changes: 4 additions & 0 deletions osv/ecosystems/maven_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def check_versions_order(self, *versions):
parsed_versions[j],
parsed_versions[i],
msg=f'Expected {versions[j]} > {versions[i]}')
self.assertGreaterEqual(
parsed_versions[j],
parsed_versions[i],
msg=f'Expected {versions[j]} >= {versions[i]}')

def check_versions_equal(self, *versions):
"""Check that the provided versions are equivalent."""
Expand Down

0 comments on commit 58fd10d

Please sign in to comment.