Add description for commands disabled in slave mode
Running the `gerrit` ssh command without arguments to a server that is running in slave mode results in a list of available commands being shown. In this list, the commands that are disabled in slave mode do not have any description. Add a description mentioning that the command is disabled due to the server running in slave mode. Bug: Issue 2424 Change-Id: Iffc43a921e70a9ed9008a62dcec12b80683b71b3
This commit is contained in:
		| @@ -21,6 +21,7 @@ import com.google.gerrit.extensions.restapi.AuthException; | ||||
| import com.google.gerrit.server.CurrentUser; | ||||
| import com.google.gerrit.server.account.CapabilityUtils; | ||||
| import com.google.gerrit.server.args4j.SubcommandHandler; | ||||
| import com.google.gerrit.sshd.commands.ErrorSlaveMode; | ||||
| import com.google.inject.Inject; | ||||
| import com.google.inject.Provider; | ||||
| import com.google.inject.assistedinject.Assisted; | ||||
| @@ -154,9 +155,13 @@ final class DispatchCommand extends BaseCommand { | ||||
|     String format = "%-" + maxLength + "s   %s"; | ||||
|     for (String name : Sets.newTreeSet(commands.keySet())) { | ||||
|       final CommandProvider p = commands.get(name); | ||||
|       Command c = p.getProvider().get(); | ||||
|       String description = c instanceof ErrorSlaveMode | ||||
|           ? "Command disabled: server is running in slave mode" | ||||
|           : Strings.nullToEmpty(p.getDescription()); | ||||
|  | ||||
|       usage.append("   "); | ||||
|       usage.append(String.format(format, name, | ||||
|           Strings.nullToEmpty(p.getDescription()))); | ||||
|       usage.append(String.format(format, name, description)); | ||||
|       usage.append("\n"); | ||||
|     } | ||||
|     usage.append("\n"); | ||||
|   | ||||
| @@ -25,7 +25,7 @@ import java.io.IOException; | ||||
|  * server. This is used when a user tries to run a command on a server in Slave | ||||
|  * Mode, but the command only applies to the Master server. | ||||
|  */ | ||||
| final class ErrorSlaveMode extends BaseCommand { | ||||
| public final class ErrorSlaveMode extends BaseCommand { | ||||
|   @Override | ||||
|   public void start(final Environment env) { | ||||
|     String msg = | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 David Pursehouse
					David Pursehouse