[extensions-web/wip/gnome-40: 5/5] extensions: add support for new GNOME version scheme
- From: Yuri Konotopov <ykonotopov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web/wip/gnome-40: 5/5] extensions: add support for new GNOME version scheme
- Date: Sat, 19 Dec 2020 17:06:52 +0000 (UTC)
commit ee139947d7de8f4daba9e14d594aa86aca7ad74b
Author: Yuri Konotopov <ykonotopov gnome org>
Date: Sat Dec 19 21:06:01 2020 +0400
extensions: add support for new GNOME version scheme
See-Also: https://discourse.gnome.org/t/new-gnome-versioning-scheme/4235
sweettooth/extensions/models.py | 23 ++++++++++++++++-------
sweettooth/extensions/tests.py | 20 ++++++++++++++++++++
2 files changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/sweettooth/extensions/models.py b/sweettooth/extensions/models.py
index 432350b9..824473fc 100644
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@ -197,26 +197,35 @@ class InvalidShellVersion(Exception):
def parse_version_string(version_string):
version = version_string.split('.')
+ version_parts = len(version)
+
+ if version_parts < 2 or version_parts > 4:
+ raise InvalidShellVersion()
try:
major, minor = version[:2]
- major, minor = int(major), int(minor)
+ major, minor = int(major)
+ # GNOME 40+
+ # https://discourse.gnome.org/t/new-gnome-versioning-scheme/4235
+ if major >= 40 and minor in ('alpha', 'beta', 'rc'):
+ minor = -1
+ else:
+ minor = int(minor)
except ValueError:
raise InvalidShellVersion()
- if len(version) in (3, 4):
+ if version_parts in (3, 4):
# 3.0.1, 3.1.4
try:
point = int(version[2])
except ValueError:
raise InvalidShellVersion()
- elif len(version) == 2 and minor % 2 == 0:
- # 3.0, 3.2
- point = -1
else:
- # Two-digit odd versions are illegal: 3.1, 3.3
- raise InvalidShellVersion()
+ point = -1
+ if major < 40 and minor % 2 != 0:
+ # Two-digit pre-40 odd versions are illegal: 3.1, 3.3
+ raise InvalidShellVersion()
return major, minor, point
diff --git a/sweettooth/extensions/tests.py b/sweettooth/extensions/tests.py
index c239cd60..125117e4 100644
--- a/sweettooth/extensions/tests.py
+++ b/sweettooth/extensions/tests.py
@@ -348,6 +348,20 @@ class ShellVersionTest(TestCase):
self.assertEqual(version.minor, 2)
self.assertEqual(version.point, -1)
+ self.assertEqual(lookup_version("40.alpha"), None)
+ version = get_version("40.alpha")
+ self.assertEqual(lookup_version("40.alpha"), version)
+ self.assertEqual(version.major, 40)
+ self.assertEqual(version.minor, -1)
+ self.assertEqual(version.point, -1)
+
+ self.assertEqual(lookup_version("41.3"), None)
+ version = get_version("41.3")
+ self.assertEqual(lookup_version("41.3"), version)
+ self.assertEqual(version.major, 41)
+ self.assertEqual(version.minor, 3)
+ self.assertEqual(version.point, -1)
+
version1 = get_version("3.2.2")
self.assertEqual(lookup_version("3.2.2.1"), version1)
@@ -357,6 +371,9 @@ class ShellVersionTest(TestCase):
with self.assertRaises(models.InvalidShellVersion):
lookup_version("3.1")
+ with self.assertRaises(models.InvalidShellVersion):
+ lookup_version("3.beta")
+
def test_bad_shell_versions(self):
with self.assertRaises(models.InvalidShellVersion):
models.parse_version_string("3")
@@ -370,6 +387,9 @@ class ShellVersionTest(TestCase):
with self.assertRaises(models.InvalidShellVersion):
models.parse_version_string("3.2.a")
+ with self.assertRaises(models.InvalidShellVersion):
+ models.parse_version_string("40.teta")
+
class DownloadExtensionTest(BasicUserTestCase, TestCase):
def download(self, uuid, shell_version):
url = reverse('extensions-shell-download', kwargs=dict(uuid=uuid))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]