[extensions-web] js: Make findNextHighestVersion work properly when passing a smaller version
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] js: Make findNextHighestVersion work properly when passing a smaller version
- Date: Thu, 8 Dec 2011 20:24:53 +0000 (UTC)
commit 34e52d9c0cdb1430c33dde4728698fb9909c6115
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Dec 8 15:19:08 2011 -0500
js: Make findNextHighestVersion work properly when passing a smaller version
sweettooth/static/js/extensionUtils.js | 11 ++++++++++-
sweettooth/static/js/extensions.js | 12 ++++++++++--
sweettooth/static/js/test/extensions.js | 24 +++++++++++++++++++-----
3 files changed, 39 insertions(+), 8 deletions(-)
---
diff --git a/sweettooth/static/js/extensionUtils.js b/sweettooth/static/js/extensionUtils.js
index 9309dad..fc76368 100644
--- a/sweettooth/static/js/extensionUtils.js
+++ b/sweettooth/static/js/extensionUtils.js
@@ -88,7 +88,16 @@ define([], function() {
nextHighestParts = parts;
});
- return nextHighestParts.join('.');
+ // In this case, it's a downgrade.
+ if (nextHighestParts[0] === Infinity ||
+ nextHighestParts[1] === Infinity ||
+ nextHighestParts[2] === Infinity) {
+ return {'operation': 'downgrade'};
+ }
+
+ return {'operation': 'upgrade',
+ 'stability': (nextHighestParts[1] % 2 === 0) ? 'stable' : 'unstable',
+ 'version': nextHighestParts.join('.')};
};
return module;
diff --git a/sweettooth/static/js/extensions.js b/sweettooth/static/js/extensions.js
index 956ce66..715f237 100644
--- a/sweettooth/static/js/extensions.js
+++ b/sweettooth/static/js/extensions.js
@@ -280,8 +280,16 @@ function($, messages, dbusProxy, extensionUtils) {
$extension.bind('out-of-date', function() {
var svm = $extension.data('svm');
- var nextHighestVersion = extensionUtils.findNextHighestVersion(svm, dbusProxy.ShellVersion);
- messages.addError("This extension is incompatible with your version of GNOME. Please upgrade to GNOME " + nextHighestVersion);
+ var nhvOperation = extensionUtils.findNextHighestVersion(svm, dbusProxy.ShellVersion);
+ if (nhvOperation.operation === 'upgrade' &&
+ nhvOperation.stability === 'stable') {
+ messages.addError("This extension is incompatible with your version of GNOME. Please upgrade to GNOME " + nextHighestVersion);
+ } else if (nhvOperation.operation === 'upgrade' &&
+ nhvOperation.stability === 'unstable') {
+ messages.addError("This extension is incompatible with your version of GNOME. This extension supports the GNOME unstable release, " + nextHighestVersion);
+ } else if (nhvOperation.operation === 'downgrade') {
+ messages.addError("This extension is incompatible with your version of GNOME.");
+ }
});
dbusProxy.GetExtensionInfo(uuid).done(function(meta) {
diff --git a/sweettooth/static/js/test/extensions.js b/sweettooth/static/js/test/extensions.js
index 7bc0cad..590e476 100644
--- a/sweettooth/static/js/test/extensions.js
+++ b/sweettooth/static/js/test/extensions.js
@@ -30,12 +30,26 @@ require(['extensionUtils', 'jquery', 'test/qunit'], function(extensionUtils) {
equal(grabProperExtensionVersion(map, "3.3.1").version, 6);
});
+ function nhvEqual(versions, current, operation, stability, version) {
+ var vm = {};
+ versions.forEach(function(v) { vm[v] = true; });
+
+ var nhv = findNextHighestVersion(vm, current);
+ equal(nhv.operation, operation);
+
+ if (operation === "stable") {
+ equal(nhv.stability, stability);
+ equal(nhv.version, version);
+ }
+ }
+
var findNextHighestVersion = extensionUtils.findNextHighestVersion;
test("findNextHighestVersion", function() {
- equal(findNextHighestVersion({ "3.2": true }, "3.0"), "3.2.0");
- equal(findNextHighestVersion({ "3.2.1": true }, "3.0"), "3.2.1");
- equal(findNextHighestVersion({ "3.2.1": true, "3.0": true }, "3.2"), "3.2.1");
- equal(findNextHighestVersion({ "3.3": true, "3.0": true }, "3.2"), "3.3.0");
- equal(findNextHighestVersion({ "3.2.1": true, "3.0": true, "3.3.1": true }, "3.2"), "3.2.1");
+ nhvEqual(["3.2"], "3.0.0", "upgrade", "stable", "3.2");
+ nhvEqual(["3.2.1"], "3.0.0", "upgrade", "stable", "3.2");
+ nhvEqual(["3.2.1", "3.0"], "3.2.0", "upgrade", "stable", "3.2.1");
+ nhvEqual(["3.3", "3.0"], "3.2.0", "upgrade", "unstable", "3.3");
+ nhvEqual(["3.2.1", "3.0", "3.3.1"], "3.2.0", "upgrade", "stable", "3.2.1");
+ nhvEqual(["3.0"], "3.2.0", "downgrade");
});
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]