summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2014-04-17 23:03:34 -0400
committerJames Moger <james.moger@gitblit.com>2014-04-17 23:08:07 -0400
commit80cf76b88cb9b9c1696c48fd418c0cdee995812c (patch)
tree972b4b5dc2fd76743f35747ea0c9b4389d8af922
parent6b254fe9f76c202065153ac045859b8434c81c73 (diff)
downloadgitblit-80cf76b88cb9b9c1696c48fd418c0cdee995812c.tar.gz
gitblit-80cf76b88cb9b9c1696c48fd418c0cdee995812c.zip
Filter the current plugin release by the system version
-rw-r--r--src/main/java/com/gitblit/manager/PluginManager.java2
-rw-r--r--src/main/java/com/gitblit/models/PluginRegistry.java32
-rw-r--r--src/main/java/com/gitblit/transport/ssh/commands/PluginDispatcher.java24
3 files changed, 49 insertions, 9 deletions
diff --git a/src/main/java/com/gitblit/manager/PluginManager.java b/src/main/java/com/gitblit/manager/PluginManager.java
index 40d302dd..9e6a31f6 100644
--- a/src/main/java/com/gitblit/manager/PluginManager.java
+++ b/src/main/java/com/gitblit/manager/PluginManager.java
@@ -403,7 +403,7 @@ public class PluginManager implements IPluginManager, PluginStateListener {
PluginRelease pv;
if (StringUtils.isEmpty(version)) {
- pv = reg.getCurrentRelease();
+ pv = reg.getCurrentRelease(getSystemVersion());
} else {
pv = reg.getRelease(version);
}
diff --git a/src/main/java/com/gitblit/models/PluginRegistry.java b/src/main/java/com/gitblit/models/PluginRegistry.java
index ef463163..0c5d5a19 100644
--- a/src/main/java/com/gitblit/models/PluginRegistry.java
+++ b/src/main/java/com/gitblit/models/PluginRegistry.java
@@ -93,19 +93,40 @@ public class PluginRegistry implements Serializable {
this.releases = new ArrayList<PluginRelease>();
}
- public PluginRelease getCurrentRelease() {
+ public PluginRelease getCurrentRelease(Version system) {
PluginRelease current = null;
if (!StringUtils.isEmpty(currentRelease)) {
// find specified
current = getRelease(currentRelease);
}
+ if (current != null) {
+ // verify the current release is acceptable for this system
+ Version requires = Version.ZERO;
+ if (!StringUtils.isEmpty(current.requires)) {
+ requires = Version.createVersion(current.requires);
+ }
+
+ if (!system.isZero() && !system.atLeast(requires)) {
+ // requires newer system version
+ current = null;
+ }
+ }
+
if (current == null) {
// find by date
Date date = new Date(0);
for (PluginRelease pv : releases) {
- if (pv.date.after(date)) {
- current = pv;
+ Version requires = Version.ZERO;
+ if (!StringUtils.isEmpty(pv.requires)) {
+ requires = Version.createVersion(pv.requires);
+ }
+
+ if (system.isZero() || system.atLeast(requires)) {
+ if (pv.date.after(date)) {
+ current = pv;
+ date = pv.date;
+ }
}
}
}
@@ -143,7 +164,10 @@ public class PluginRegistry implements Serializable {
}
}
- public static class PluginRelease implements Comparable<PluginRelease> {
+ public static class PluginRelease implements Serializable, Comparable<PluginRelease> {
+
+ private static final long serialVersionUID = 1L;
+
public String version;
public Date date;
public String requires;
diff --git a/src/main/java/com/gitblit/transport/ssh/commands/PluginDispatcher.java b/src/main/java/com/gitblit/transport/ssh/commands/PluginDispatcher.java
index 6f8f95ae..15345cac 100644
--- a/src/main/java/com/gitblit/transport/ssh/commands/PluginDispatcher.java
+++ b/src/main/java/com/gitblit/transport/ssh/commands/PluginDispatcher.java
@@ -259,10 +259,18 @@ public class PluginDispatcher extends DispatchCommand {
}
protected String buildFieldTable(PluginWrapper pw, PluginRegistration reg) {
+ Version system = getContext().getGitblit().getSystemVersion();
+ PluginRelease current = reg == null ? null : reg.getCurrentRelease(system);
+ if (current == null) {
+ current = new PluginRelease();
+ current.version = "";
+ current.requires = "";
+ }
+
final String id = pw == null ? reg.id : pw.getPluginId();
final String description = reg == null ? pw.getDescriptor().getPluginDescription() : reg.description;
- final String version = pw == null ? reg.getCurrentRelease().version : pw.getDescriptor().getVersion().toString();
- final String requires = pw == null ? reg.getCurrentRelease().requires : pw.getDescriptor().getRequires().toString();
+ final String version = pw == null ? current.version : pw.getDescriptor().getVersion().toString();
+ final String requires = pw == null ? current.requires : pw.getDescriptor().getRequires().toString();
final String provider = pw == null ? reg.provider : pw.getDescriptor().getProvider();
final String registry = reg == null ? "" : reg.registry;
final String path = pw == null ? "" : pw.getPluginPath();
@@ -470,10 +478,14 @@ public class PluginDispatcher extends DispatchCommand {
String [] h = { "Id", "Installed", "Current", "Requires", "State" };
headers = h;
}
+ Version system = getContext().getGitblit().getSystemVersion();
Object[][] data = new Object[list.size()][];
for (int i = 0; i < list.size(); i++) {
PluginRegistration p = list.get(i);
- PluginRelease curr = p.getCurrentRelease();
+ PluginRelease curr = p.getCurrentRelease(system);
+ if (curr == null) {
+ curr = new PluginRelease();
+ }
if (verbose) {
data[i] = new Object[] {p.id, p.description, p.installedRelease, curr.version, curr.requires, p.getInstallState(), p.registry};
} else {
@@ -486,8 +498,12 @@ public class PluginDispatcher extends DispatchCommand {
@Override
protected void asTabbed(List<PluginRegistration> list) {
+ Version system = getContext().getGitblit().getSystemVersion();
for (PluginRegistration p : list) {
- PluginRelease curr = p.getCurrentRelease();
+ PluginRelease curr = p.getCurrentRelease(system);
+ if (curr == null) {
+ curr = new PluginRelease();
+ }
if (verbose) {
outTabbed(p.id, p.description, p.installedRelease, curr.version, curr.requires, p.getInstallState(), p.provider, p.registry);
} else {