-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ecosystems): support Red Hat fully (#2667)
Red Hat records are not importing as intended, I believe this will correct that.
- Loading branch information
1 parent
d4aed31
commit c6d9ca5
Showing
4 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Red Hat Linux ecosystem helper.""" | ||
|
||
from ..third_party.univers.rpm import RpmVersion | ||
from .helper_base import Ecosystem | ||
|
||
|
||
class RedHat(Ecosystem): | ||
"""Red Hat Linux ecosystem""" | ||
|
||
@property | ||
def name(self): | ||
return 'Red Hat' | ||
|
||
def sort_key(self, version): | ||
return RpmVersion.from_string(version) | ||
|
||
def enumerate_versions(self, | ||
package, | ||
introduced, | ||
fixed=None, | ||
last_affected=None, | ||
limits=None): | ||
raise NotImplementedError('Ecosystem helper does not support enumeration') | ||
|
||
@property | ||
def supports_comparing(self): | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Red Hat Linux ecosystem helper tests.""" | ||
|
||
import unittest | ||
from .. import ecosystems | ||
|
||
|
||
class RedHatEcosystemTest(unittest.TestCase): | ||
"""Red Hat Linux ecosystem helper tests.""" | ||
|
||
def test_redhat(self): | ||
"""Test sort_key""" | ||
ecosystem = ecosystems.get('Red Hat') | ||
self.assertEqual('Red Hat', ecosystem.name) | ||
self.assertGreater( | ||
ecosystem.sort_key('0:0.2.6-20.module+el8.9.0+1420+91577025'), | ||
ecosystem.sort_key('0:0.0.99.4-5.module+el8.9.0+1445+07728297')) | ||
self.assertGreater( | ||
ecosystem.sort_key('0:0.2.6-20.module+el8.9.0+1420+91577025'), | ||
ecosystem.sort_key('0')) | ||
self.assertGreater( | ||
ecosystem.sort_key('2:1.14.3-2.module+el8.10.0+1815+5fe7415e'), | ||
ecosystem.sort_key('2:1.10.3-1.module+el8.10.0+1815+5fe7415e')) | ||
self.assertLess(ecosystem.sort_key('invalid'), ecosystem.sort_key('0')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters