提交 00afaa52 编写于 作者: A abayer

[FIXED HUDSON-4056] Added support for marking a new plugin version as...

[FIXED HUDSON-4056] Added support for marking a new plugin version as configuration-incompatible with previous versions - see http://wiki.hudson-ci.org/display/HUDSON/Marking+a+new+plugin+version+as+incompatible+with+older+versions

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@21097 71c3de6d-444a-0410-be80-ed276b4c234a
上级 cbb3e313
......@@ -405,8 +405,22 @@ public class UpdateCenter extends AbstractModelObject {
* false otherwise, including the situation where the strings couldn't be parsed as version numbers.
*/
public boolean isNewerThan(String currentVersion) {
return isNewerThan(currentVersion, version);
}
/**
* Compares two versions - returns true if the first version is newer than the second.
*
* @param firstVersion
* The first version to test against.
* @param secondVersion
* The second version to test against.
* @return
* True if the first version is newer than the second version. False in all other cases.
*/
public boolean isNewerThan(String firstVersion, String secondVersion) {
try {
return new VersionNumber(currentVersion).compareTo(new VersionNumber(version)) < 0;
return new VersionNumber(firstVersion).compareTo(new VersionNumber(secondVersion)) < 0;
} catch (IllegalArgumentException e) {
// couldn't parse as the version number.
return false;
......@@ -431,13 +445,18 @@ public class UpdateCenter extends AbstractModelObject {
* Optional excerpt string.
*/
public final String excerpt;
/**
* Optional version # from which this plugin release is configuration-compatible.
*/
public final String compatibleSinceVersion;
@DataBoundConstructor
public Plugin(JSONObject o) {
super(o);
this.wiki = get(o,"wiki");
this.title = get(o,"title");
this.excerpt = get(o,"excerpt");
this.compatibleSinceVersion = get(o,"compatibleSinceVersion");
}
private String get(JSONObject o, String prop) {
......@@ -461,6 +480,26 @@ public class UpdateCenter extends AbstractModelObject {
return pm.getPlugin(name);
}
/**
* If the plugin is already installed, and the new version of the plugin has a "compatibleSinceVersion"
* value (i.e., it's only directly compatible with that version or later), this will check to
* see if the installed version is older than the compatible-since version. If it is older, it'll return false.
* If it's not older, or it's not installed, or it's installed but there's no compatibleSinceVersion
* specified, it'll return true.
*/
public boolean isCompatibleWithInstalledVersion() {
PluginWrapper installedVersion = getInstalled();
if (installedVersion != null) {
if (compatibleSinceVersion != null) {
if (new VersionNumber(installedVersion.getVersion())
.isOlderThan(new VersionNumber(compatibleSinceVersion))) {
return false;
}
}
}
return true;
}
/**
* Schedules the installation of this plugin.
*
......
......@@ -53,7 +53,13 @@ THE SOFTWARE.
<j:if test="${p.excerpt!=null}">
<div class="excerpt">${p.excerpt}</div>
</j:if>
</td>
<j:if test="${!p.isCompatibleWithInstalledVersion()}">
<div class="compatWarning">${%Warning: New
version not compatible with installed
version. Jobs using this plugin may need to be
reconfigured.}</div>
</j:if>
</td>
<td class="pane"><st:out value="${p.version}" /></td>
</tr>
</j:forEach>
......
......@@ -821,6 +821,13 @@ TEXTAREA.rich-editor {
color: #888a85;
}
#plugins .compatWarning {
white-space: normal;
margin-top: 0.5em;
padding-left: 2em;
color: #FF0000;
}
/* ========================= progress bar ========================= */
table.progress-bar {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册