From 95806c6a5899292fc1e9750e7df8c37ded0f41c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 26 Feb 2021 00:47:48 +0100 Subject: [PATCH] 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: --- 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 d9a5721cf..a8133d8a2 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 ... - * is always ignored - * is ignored if is even (so you can target the - * whole stable release) - * and must match - * Each target version must be at least and - */ -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) {