LCOV - code coverage report
Current view: top level - server/change - MergeabilityComputationBehavior.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 11 11 100.0 %
Date: 2022-11-19 15:00:39 Functions: 5 5 100.0 %

          Line data    Source code
       1             : // Copyright (C) 2020 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.server.change;
      16             : 
      17             : import org.eclipse.jgit.lib.Config;
      18             : 
      19             : /**
      20             :  * State that is used to decide if {@code mergeable} should be included in the REST API or the
      21             :  * change index.
      22             :  *
      23             :  * <p>Computing mergeability of a change is an expensive operation - especially for Gerrit
      24             :  * installations with a large number of open changes or large repositories. Therefore, we want to
      25             :  * control when this computation is performed.
      26             :  */
      27         151 : public enum MergeabilityComputationBehavior {
      28         151 :   NEVER(false, false),
      29         151 :   REF_UPDATED_AND_CHANGE_REINDEX(true, false),
      30         151 :   API_REF_UPDATED_AND_CHANGE_REINDEX(true, true);
      31             : 
      32             :   private final boolean includeInIndex;
      33             :   private final boolean includeInApi;
      34             : 
      35         151 :   MergeabilityComputationBehavior(boolean includeInIndex, boolean includeInApi) {
      36         151 :     this.includeInIndex = includeInIndex;
      37         151 :     this.includeInApi = includeInApi;
      38         151 :   }
      39             : 
      40             :   /** Returns a {@link MergeabilityComputationBehavior} constructed from a Gerrit server config. */
      41             :   public static MergeabilityComputationBehavior fromConfig(Config cfg) {
      42         151 :     return cfg.getEnum(
      43             :         "change", null, "mergeabilityComputationBehavior", MergeabilityComputationBehavior.NEVER);
      44             :   }
      45             : 
      46             :   /** Whether {@code mergeable} should be included in the change API. */
      47             :   public boolean includeInApi() {
      48         103 :     return includeInApi;
      49             :   }
      50             : 
      51             :   /** Whether {@code mergeable} should be included in the change index. */
      52             :   public boolean includeInIndex() {
      53         151 :     return includeInIndex;
      54             :   }
      55             : }

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