PushConfig.java

  1. /*
  2.  * Copyright (C) 2017, David Pursehouse <david.pursehouse@gmail.com> and others
  3.  *
  4.  * This program and the accompanying materials are made available under the
  5.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  6.  * https://www.eclipse.org/org/documents/edl-v10.php.
  7.  *
  8.  * SPDX-License-Identifier: BSD-3-Clause
  9.  */

  10. package org.eclipse.jgit.transport;

  11. import org.eclipse.jgit.lib.Config;
  12. import org.eclipse.jgit.util.StringUtils;

  13. /**
  14.  * Push section of a Git configuration file.
  15.  *
  16.  * @since 4.9
  17.  */
  18. public class PushConfig {
  19.     /**
  20.      * Config values for push.recurseSubmodules.
  21.      */
  22.     public enum PushRecurseSubmodulesMode implements Config.ConfigEnum {
  23.         /**
  24.          * Verify that all submodule commits that changed in the revisions to be
  25.          * pushed are available on at least one remote of the submodule.
  26.          */
  27.         CHECK("check"), //$NON-NLS-1$

  28.         /**
  29.          * All submodules that changed in the revisions to be pushed will be
  30.          * pushed.
  31.          */
  32.         ON_DEMAND("on-demand"), //$NON-NLS-1$

  33.         /** Default behavior of ignoring submodules when pushing is retained. */
  34.         NO("false"); //$NON-NLS-1$

  35.         private final String configValue;

  36.         private PushRecurseSubmodulesMode(String configValue) {
  37.             this.configValue = configValue;
  38.         }

  39.         @Override
  40.         public String toConfigValue() {
  41.             return configValue;
  42.         }

  43.         @Override
  44.         public boolean matchConfigValue(String s) {
  45.             if (StringUtils.isEmptyOrNull(s)) {
  46.                 return false;
  47.             }
  48.             s = s.replace('-', '_');
  49.             return name().equalsIgnoreCase(s)
  50.                     || configValue.equalsIgnoreCase(s);
  51.         }
  52.     }
  53. }