@Option(name = "--noverify", usage = "Disable checksum verification")
private boolean disableChecksum;
@Override
public void run() throws Failure {
IGitblit gitblit = getContext().getGitblit();
try {
String ulc = urlOrId.toLowerCase();
if (ulc.startsWith("http://") || ulc.startsWith("https://")) {
if (gitblit.installPlugin(urlOrId, !disableChecksum)) {
stdout.println(String.format("Installed %s", urlOrId));
} else {
throw new UnloggedFailure(1, String.format("Failed to install %s", urlOrId));
}
} else {
PluginRelease pr = gitblit.lookupRelease(urlOrId, version);
if (pr == null) {
throw new UnloggedFailure(1, String.format("Plugin \"%s\" is not in the registry!", urlOrId));
}
// 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) {
String msg = String.format("Plugin \"%s:%s\" requires Gitblit %s",
urlOrId, pr.version, pr.requires);
throw new UnloggedFailure(1, msg);
}
}
if (gitblit.installPlugin(pr.url, !disableChecksum)) {
stdout.println(String.format("Installed %s", urlOrId));
} else {
throw new UnloggedFailure(1, String.format("Failed to install %s", urlOrId));
}
}