View Javadoc
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  
11  package org.eclipse.jgit.transport;
12  
13  import org.eclipse.jgit.lib.Config;
14  import org.eclipse.jgit.util.StringUtils;
15  
16  /**
17   * Push section of a Git configuration file.
18   *
19   * @since 4.9
20   */
21  public class PushConfig {
22  	/**
23  	 * Config values for push.recurseSubmodules.
24  	 */
25  	public enum PushRecurseSubmodulesMode implements Config.ConfigEnum {
26  		/**
27  		 * Verify that all submodule commits that changed in the revisions to be
28  		 * pushed are available on at least one remote of the submodule.
29  		 */
30  		CHECK("check"), //$NON-NLS-1$
31  
32  		/**
33  		 * All submodules that changed in the revisions to be pushed will be
34  		 * pushed.
35  		 */
36  		ON_DEMAND("on-demand"), //$NON-NLS-1$
37  
38  		/** Default behavior of ignoring submodules when pushing is retained. */
39  		NO("false"); //$NON-NLS-1$
40  
41  		private final String configValue;
42  
43  		private PushRecurseSubmodulesMode(String configValue) {
44  			this.configValue = configValue;
45  		}
46  
47  		@Override
48  		public String toConfigValue() {
49  			return configValue;
50  		}
51  
52  		@Override
53  		public boolean matchConfigValue(String s) {
54  			if (StringUtils.isEmptyOrNull(s)) {
55  				return false;
56  			}
57  			s = s.replace('-', '_');
58  			return name().equalsIgnoreCase(s)
59  					|| configValue.equalsIgnoreCase(s);
60  		}
61  	}
62  }