Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions src/univers/version_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,11 @@ def from_native(cls, string):
return cls(constraints=constraints)


class MattermostVersionRange(VersionRange):
scheme = "mattermost"
version_class = versions.SemverVersion


def from_gitlab_native(gitlab_scheme, string):
purl_scheme = PURL_TYPE_BY_GITLAB_SCHEME[gitlab_scheme]
vrc = RANGE_CLASS_BY_SCHEMES[purl_scheme]
Expand Down Expand Up @@ -1217,6 +1222,7 @@ def build_range_from_github_advisory_constraint(scheme: str, string: str):
"alpm": ArchLinuxVersionRange,
"nginx": NginxVersionRange,
"openssl": OpensslVersionRange,
"mattermost": MattermostVersionRange,
}

PURL_TYPE_BY_GITLAB_SCHEME = {
Expand Down
16 changes: 15 additions & 1 deletion tests/test_version_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pytest

from univers.version_constraint import VersionConstraint
from univers.version_range import GemVersionRange
from univers.version_range import GemVersionRange, MattermostVersionRange
Comment thread
pombredanne marked this conversation as resolved.
Outdated
from univers.version_range import from_gitlab_native
from univers.version_range import NugetVersionRange
from univers.version_range import InvalidVersionRange
Expand Down Expand Up @@ -413,3 +413,17 @@ def test_invert():

vers_with_star_operator = VersionRange.from_string("vers:gem/*")
assert vers_with_star_operator.invert() == None


def test_mattermost_version_range():
assert MattermostVersionRange(
constraints=[
VersionConstraint(comparator="=", version=SemverVersion("5.0")),
]
) == VersionRange.from_string("vers:mattermost/5.0")

assert MattermostVersionRange(
constraints=[
VersionConstraint(comparator=">=", version=SemverVersion("5.0")),
]
) == VersionRange.from_string("vers:mattermost/>=5.0")