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>
This commit is contained in:
parent
48ae38c52d
commit
95806c6a58
@ -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) {
|
function isOutOfDate(extension) {
|
||||||
if (!versionCheck(extension.metadata['shell-version'], Config.PACKAGE_VERSION))
|
const [major] = Config.PACKAGE_VERSION.split('.');
|
||||||
return true;
|
return !extension.metadata['shell-version'].some(v => v.startsWith(major));
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializeExtension(extension) {
|
function serializeExtension(extension) {
|
||||||
|
Loading…
Reference in New Issue
Block a user