Add '--install-plugin' option to init step
This allows automatically install given plugin without asking. Can be also used together with '--batch' to automatically install/update Gerrit without interactions. Change-Id: I8e0cf8f2e39c813e54daff6b587cb8cd2485bae8 Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
This commit is contained in:
@@ -23,6 +23,7 @@ import org.eclipse.jgit.storage.file.FileBasedConfig;
|
||||
import org.eclipse.jgit.util.FS;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/** Global variables used by the 'init' command. */
|
||||
@Singleton
|
||||
@@ -35,9 +36,13 @@ public class InitFlags {
|
||||
|
||||
public final FileBasedConfig cfg;
|
||||
public final FileBasedConfig sec;
|
||||
public final List<String> installPlugins;
|
||||
|
||||
@Inject
|
||||
InitFlags(final SitePaths site) throws IOException, ConfigInvalidException {
|
||||
InitFlags(final SitePaths site,
|
||||
final @InstallPlugins List<String> installPlugins) throws IOException,
|
||||
ConfigInvalidException {
|
||||
this.installPlugins = installPlugins;
|
||||
cfg = new FileBasedConfig(site.gerrit_config, FS.DETECTED);
|
||||
sec = new FileBasedConfig(site.secure_config, FS.DETECTED);
|
||||
|
||||
|
@@ -84,12 +84,15 @@ public class InitPlugins implements InitStep {
|
||||
|
||||
private final ConsoleUI ui;
|
||||
private final SitePaths site;
|
||||
private InitPluginStepsLoader pluginLoader;
|
||||
private final InitFlags initFlags;
|
||||
private final InitPluginStepsLoader pluginLoader;
|
||||
|
||||
@Inject
|
||||
InitPlugins(final ConsoleUI ui, final SitePaths site, InitPluginStepsLoader pluginLoader) {
|
||||
InitPlugins(final ConsoleUI ui, final SitePaths site,
|
||||
InitFlags initFlags, InitPluginStepsLoader pluginLoader) {
|
||||
this.ui = ui;
|
||||
this.site = site;
|
||||
this.initFlags = initFlags;
|
||||
this.pluginLoader = pluginLoader;
|
||||
}
|
||||
|
||||
@@ -108,8 +111,8 @@ public class InitPlugins implements InitStep {
|
||||
try {
|
||||
final File tmpPlugin = plugin.pluginFile;
|
||||
|
||||
if (!ui.yesno(false, "Install plugin %s version %s", pluginName,
|
||||
plugin.version)) {
|
||||
if (!(initFlags.installPlugins.contains(pluginName) || ui.yesno(false,
|
||||
"Install plugin %s version %s", pluginName, plugin.version))) {
|
||||
tmpPlugin.delete();
|
||||
continue;
|
||||
}
|
||||
|
@@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2013 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.pgm.init;
|
||||
|
||||
import com.google.inject.BindingAnnotation;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@BindingAnnotation
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface InstallPlugins {
|
||||
}
|
Reference in New Issue
Block a user