Line data Source code
1 : // Copyright (C) 2011 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.sshd.commands; 16 : 17 : import static com.google.gerrit.sshd.CommandMetaData.Mode.MASTER_OR_SLAVE; 18 : 19 : import com.google.gerrit.common.Version; 20 : import com.google.gerrit.sshd.CommandMetaData; 21 : import com.google.gerrit.sshd.SshCommand; 22 : 23 : @CommandMetaData(name = "version", description = "Display gerrit version", runsAt = MASTER_OR_SLAVE) 24 2 : final class VersionCommand extends SshCommand { 25 : 26 : @Override 27 : protected void run() throws Failure { 28 1 : enableGracefulStop(); 29 1 : String v = Version.getVersion(); 30 1 : if (v == null) { 31 0 : throw new Failure(1, "fatal: version unavailable"); 32 : } 33 : 34 1 : stdout.println("gerrit version " + v); 35 1 : } 36 : }