[gnome-shell] extensionUtils: Simplify version check



commit 95806c6a5899292fc1e9750e7df8c37ded0f41c3
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Feb 26 00:47:48 2021 +0100

    extensionUtils: Simplify version check
    
    When adapting the check to the new versioning check, we just blindly
    copied the old behavior for stable/unstable versions:
    
     - stable releases must have matching major numbers
     - unstable releases must match major and minor ("alpha", "beta", "rc")
    
    That worked for the old even/odd scheme, but now has the absurd effect
    that we consider an extension that lists "40.alpha" in its shell-version
    incompatible with "40.beta", but compatible with "40.2".
    
    At least this provides us with a good opportunity to reconsider the
    behavior. While it is true that breakage is much more likely between
    unstable releases, in practice extensions are either following shell
    development closely or update once around the time of a stable release.
    
    For the former, the stricter check isn't usually too useful (as the
    extension releases around the same time as gnome-shell anyway).
    
    For the latter, it's annoying that ".rc" is treated differently from
    ".0" and requires an update to become compatible.
    
    The latter is also by far the more common case, so update the check
    to only match on the major version regardless of whether a release
    is stable or unstable.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3787
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1719>

 js/misc/extensionUtils.js | 35 ++---------------------------------
 1 file changed, 2 insertions(+), 33 deletions(-)
---
diff --git a/js/misc/extensionUtils.js b/js/misc/extensionUtils.js
index d9a5721cf5..a8133d8a2e 100644
--- a/js/misc/extensionUtils.js
+++ b/js/misc/extensionUtils.js
@@ -173,40 +173,9 @@ function openPrefs() {
     }
 }
 
-/**
- * versionCheck:
- * @param {string[]} required - an array of versions we're compatible with
- * @param {string} current - the version we have
- * @returns {bool} - true if @current is compatible with @required
- *
- * Check if a component is compatible for an extension.
- * @required is an array, and at least one version must match.
- * @current must be in the format <major>.<minor>.<point>.<micro>
- * <micro> is always ignored
- * <point> is ignored if <minor> is even (so you can target the
- * whole stable release)
- * <minor> and <major> must match
- * Each target version must be at least <major> and <minor>
- */
-function versionCheck(required, current) {
-    let currentArray = current.split('.');
-    let major = currentArray[0];
-    let minor = currentArray[1];
-    for (let i = 0; i < required.length; i++) {
-        let requiredArray = required[i].split('.');
-        if (requiredArray[0] === major &&
-            (requiredArray[1] === undefined && isFinite(minor) ||
-             requiredArray[1] === minor))
-            return true;
-    }
-    return false;
-}
-
 function isOutOfDate(extension) {
-    if (!versionCheck(extension.metadata['shell-version'], Config.PACKAGE_VERSION))
-        return true;
-
-    return false;
+    const [major] = Config.PACKAGE_VERSION.split('.');
+    return !extension.metadata['shell-version'].some(v => v.startsWith(major));
 }
 
 function serializeExtension(extension) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]