From ab19cc4c38217bd0654e931fdcf646add4b8006d Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sat, 18 Jan 2025 15:30:46 +0100 Subject: [PATCH] =?UTF-8?q?gnome.updateScript:=20Support=20Gcr=E2=80=99s?= =?UTF-8?q?=20new=20version=20policy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It uses SemVer with `micro >= 90` being considered unstable. https://gitlab.gnome.org/GNOME/gcr/-/tree/4.3.90.3#versions --- pkgs/desktops/gnome/find-latest-version.py | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/pkgs/desktops/gnome/find-latest-version.py b/pkgs/desktops/gnome/find-latest-version.py index 93252f0765ae..06874d047614 100644 --- a/pkgs/desktops/gnome/find-latest-version.py +++ b/pkgs/desktops/gnome/find-latest-version.py @@ -122,6 +122,47 @@ def odd_unstable(version: Version) -> Stability: return Stability.UNSTABLE +def ninety_micro_unstable(version: Version) -> Stability: + """ + : + > To denote unstable versions, the micro version number will correspond to 90 or + > higher, e.g. 4.$MINOR.90. + + >>> ninety_micro_unstable(Version("3.2.1")) + Stability.STABLE + >>> ninety_micro_unstable(Version("3.2.1.alpha")) + Stability.UNSTABLE + >>> ninety_micro_unstable(Version("3.2.1beta")) + Stability.UNSTABLE + >>> ninety_micro_unstable(Version("4.2.89")) + Stability.STABLE + >>> ninety_micro_unstable(Version("4.3.89")) + Stability.STABLE + >>> ninety_micro_unstable(Version("4.2.90")) + Stability.UNSTABLE + >>> ninety_micro_unstable(Version("4.2.89.3")) + Stability.STABLE + >>> ninety_micro_unstable(Version("4.2.90.3")) + Stability.UNSTABLE + >>> ninety_micro_unstable(Version("4.90.1")) + Stability.STABLE + """ + try: + version_parts = version_to_list(version.value) + except: + # Failing to parse as a list of numbers likely means the version contains a string tag like “beta”, therefore it is not a stable release. + return Stability.UNSTABLE + + if len(version_parts) < 3: + return Stability.STABLE + + prerelease = version_parts[2] >= 90 + if prerelease: + return Stability.UNSTABLE + else: + return Stability.STABLE + + def tagged(version: Version) -> Stability: """ Considers only versions with explicit `alpha`, `beta` or `rc` tags unstable. @@ -166,6 +207,7 @@ class VersionPolicyKind(Enum): # HACK: Using function as values directly would make Enum # think they are methods and skip them. ODD_UNSTABLE = VersionClassifierHolder(odd_unstable) + NINETY_MICRO_UNSTABLE = VersionClassifierHolder(ninety_micro_unstable) TAGGED = VersionClassifierHolder(tagged) NONE = VersionClassifierHolder(no_policy)