diff options
author | James Moger <james.moger@gitblit.com> | 2014-04-23 10:34:17 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-04-23 10:34:17 -0400 |
commit | 67278f5d0cd5ffec4d0a1517f2b2077ab2cbf7d4 (patch) | |
tree | 308ff845c5fa6178a5213fbf5937ed5ce0900d7a | |
parent | e22185b8b6fe1ca5d7ee43258ab2529f5ccc5630 (diff) | |
download | gitblit-67278f5d0cd5ffec4d0a1517f2b2077ab2cbf7d4.tar.gz gitblit-67278f5d0cd5ffec4d0a1517f2b2077ab2cbf7d4.zip |
Simplify current plugin release detection, ignore currentRelease registry field
-rw-r--r-- | releases.moxie | 1 | ||||
-rw-r--r-- | src/main/java/com/gitblit/manager/PluginManager.java | 2 | ||||
-rw-r--r-- | src/main/java/com/gitblit/models/PluginRegistry.java | 47 | ||||
-rw-r--r-- | src/main/java/com/gitblit/transport/ssh/commands/PluginDispatcher.java | 10 |
4 files changed, 21 insertions, 39 deletions
diff --git a/releases.moxie b/releases.moxie index 8360d778..8e183f74 100644 --- a/releases.moxie +++ b/releases.moxie @@ -12,6 +12,7 @@ r23: { fixes: ~ changes: - improve French translation (pr-176) + - simplify current plugin release detection and ignore the currentRelease registry field additions: ~ dependencyChanges: - update to Apache MINA/SSHD 0.11.0 (issue-410) diff --git a/src/main/java/com/gitblit/manager/PluginManager.java b/src/main/java/com/gitblit/manager/PluginManager.java index 9e6a31f6..2ee48558 100644 --- a/src/main/java/com/gitblit/manager/PluginManager.java +++ b/src/main/java/com/gitblit/manager/PluginManager.java @@ -377,7 +377,7 @@ public class PluginManager implements IPluginManager, PluginStateListener { List<PluginRegistration> list = getRegisteredPlugins(); Iterator<PluginRegistration> itr = list.iterator(); while (itr.hasNext()) { - if (state != itr.next().getInstallState()) { + if (state != itr.next().getInstallState(getSystemVersion())) { itr.remove(); } } diff --git a/src/main/java/com/gitblit/models/PluginRegistry.java b/src/main/java/com/gitblit/models/PluginRegistry.java index 0c5d5a19..8da34578 100644 --- a/src/main/java/com/gitblit/models/PluginRegistry.java +++ b/src/main/java/com/gitblit/models/PluginRegistry.java @@ -80,8 +80,6 @@ public class PluginRegistry implements Serializable { public String projectUrl;
- public String currentRelease;
-
public transient String installedRelease;
public transient String registry;
@@ -95,38 +93,17 @@ public class PluginRegistry implements Serializable { 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
+ Date date = new Date(0);
+ for (PluginRelease pv : releases) {
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 (!StringUtils.isEmpty(pv.requires)) {
+ requires = Version.createVersion(pv.requires);
}
- }
- if (current == null) {
- // find by date
- Date date = new Date(0);
- for (PluginRelease pv : releases) {
- 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;
- }
+ if (system.isZero() || system.atLeast(requires)) {
+ if (pv.date.after(date)) {
+ current = pv;
+ date = pv.date;
}
}
}
@@ -142,12 +119,16 @@ public class PluginRegistry implements Serializable { return null;
}
- public InstallState getInstallState() {
+ public InstallState getInstallState(Version system) {
if (StringUtils.isEmpty(installedRelease)) {
return InstallState.NOT_INSTALLED;
}
Version ir = Version.createVersion(installedRelease);
- Version cr = Version.createVersion(currentRelease);
+ Version cr = Version.ZERO;
+ PluginRelease curr = getCurrentRelease(system);
+ if (cr != null) {
+ cr = Version.createVersion(curr.version);
+ }
switch (ir.compareTo(cr)) {
case -1:
return InstallState.UNKNOWN;
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 42325e79..ce0958c3 100644 --- a/src/main/java/com/gitblit/transport/ssh/commands/PluginDispatcher.java +++ b/src/main/java/com/gitblit/transport/ssh/commands/PluginDispatcher.java @@ -283,7 +283,7 @@ public class PluginDispatcher extends DispatchCommand { state = Joiner.on(", ").join(InstallState.INSTALLED, pw.getPluginState()); } else { // registered, installed plugin - state = Joiner.on(", ").join(reg.getInstallState(), pw.getPluginState()); + state = Joiner.on(", ").join(reg.getInstallState(system), pw.getPluginState()); } StringBuilder sb = new StringBuilder(); @@ -486,9 +486,9 @@ public class PluginDispatcher extends DispatchCommand { curr = new PluginRelease(); } if (verbose) { - data[i] = new Object[] {p.id, p.description, p.installedRelease, curr.version, curr.requires, p.getInstallState(), p.registry}; + data[i] = new Object[] {p.id, p.description, p.installedRelease, curr.version, curr.requires, p.getInstallState(system), p.registry}; } else { - data[i] = new Object[] {p.id, p.installedRelease, curr.version, curr.requires, p.getInstallState()}; + data[i] = new Object[] {p.id, p.installedRelease, curr.version, curr.requires, p.getInstallState(system)}; } } @@ -504,9 +504,9 @@ public class PluginDispatcher extends DispatchCommand { curr = new PluginRelease(); } if (verbose) { - outTabbed(p.id, p.description, p.installedRelease, curr.version, curr.requires, p.getInstallState(), p.provider, p.registry); + outTabbed(p.id, p.description, p.installedRelease, curr.version, curr.requires, p.getInstallState(system), p.provider, p.registry); } else { - outTabbed(p.id, p.installedRelease, curr.version, curr.requires, p.getInstallState()); + outTabbed(p.id, p.installedRelease, curr.version, curr.requires, p.getInstallState(system)); } } } |