LCOV - code coverage report
Current view: top level - sshd/commands - SequenceShowCommand.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 1 13 7.7 %
Date: 2022-11-19 15:00:39 Functions: 1 2 50.0 %

          Line data    Source code
       1             : // Copyright (C) 2019 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 com.google.gerrit.common.data.GlobalCapability;
      18             : import com.google.gerrit.extensions.annotations.RequiresCapability;
      19             : import com.google.gerrit.server.notedb.Sequences;
      20             : import com.google.gerrit.sshd.CommandMetaData;
      21             : import com.google.gerrit.sshd.SshCommand;
      22             : import com.google.inject.Inject;
      23             : import org.kohsuke.args4j.Argument;
      24             : 
      25             : /** Display sequence value. */
      26             : @RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
      27             : @CommandMetaData(name = "show", description = "Display the sequence value")
      28           1 : final class SequenceShowCommand extends SshCommand {
      29             :   @Argument(index = 0, metaVar = "NAME", required = true, usage = "sequence name")
      30             :   private String name;
      31             : 
      32             :   @Inject Sequences sequences;
      33             : 
      34             :   @Override
      35             :   public void run() throws Exception {
      36             :     int current;
      37           0 :     switch (name) {
      38             :       case "changes":
      39           0 :         current = sequences.currentChangeId();
      40           0 :         break;
      41             :       case "accounts":
      42           0 :         current = sequences.currentAccountId();
      43           0 :         break;
      44             :       case "groups":
      45           0 :         current = sequences.currentGroupId();
      46           0 :         break;
      47             :       default:
      48           0 :         throw die("Unknown sequence name: " + name);
      49             :     }
      50           0 :     stdout.print(current);
      51           0 :     stdout.print('\n');
      52           0 :     stdout.flush();
      53           0 :   }
      54             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750