private boolean disableChecksum;
@Override
public void run() throws Failure {
IGitblit gitblit = getContext().getGitblit();
PluginWrapper pluginWrapper = getPlugin(id);
if (pluginWrapper == null) {
throw new UnloggedFailure("Invalid plugin specified!");
}
PluginRelease pr = gitblit.lookupRelease(pluginWrapper.getPluginId(), version);
if (pr == null) {
throw new UnloggedFailure(1, String.format("Plugin \"%s\" is not in the registry!", pluginWrapper.getPluginId()));
}
// enforce minimum system requirement
if (!StringUtils.isEmpty(pr.requires)) {
Version requires = Version.createVersion(pr.requires);
Version system = gitblit.getSystemVersion();
boolean isValid = system.isZero() || system.atLeast(requires);
if (!isValid) {
throw new Failure(1, String.format("Plugin \"%s:%s\" requires Gitblit %s",
pluginWrapper.getPluginId(), pr.version, pr.requires));
}
}
try {
if (gitblit.upgradePlugin(pluginWrapper.getPluginId(), pr.url, !disableChecksum)) {
stdout.println(String.format("Upgraded %s", pluginWrapper.getPluginId()));
} else {
throw new UnloggedFailure(1, String.format("Failed to upgrade %s", pluginWrapper.getPluginId()));
}
} catch (IOException e) {
log.error("Failed to upgrade " + pluginWrapper.getPluginId(), e);
throw new UnloggedFailure(1, String.format("Failed to upgrade %s", pluginWrapper.getPluginId()), e);
}
}