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.lib;
12  
13  import org.eclipse.jgit.util.StringUtils;
14  
15  /**
16   * Submodule section of a Git configuration file.
17   *
18   * @since 4.7
19   */
20  public class SubmoduleConfig {
21  
22  	/**
23  	 * Config values for submodule.[name].fetchRecurseSubmodules.
24  	 */
25  	public enum FetchRecurseSubmodulesMode implements Config.ConfigEnum {
26  		/** Unconditionally recurse into all populated submodules. */
27  		YES("true"), //$NON-NLS-1$
28  
29  		/**
30  		 * Only recurse into a populated submodule when the superproject
31  		 * retrieves a commit that updates the submodule's reference to a commit
32  		 * that isn't already in the local submodule clone.
33  		 */
34  		ON_DEMAND("on-demand"), //$NON-NLS-1$
35  
36  		/** Completely disable recursion. */
37  		NO("false"); //$NON-NLS-1$
38  
39  		private final String configValue;
40  
41  		private FetchRecurseSubmodulesMode(String configValue) {
42  			this.configValue = configValue;
43  		}
44  
45  		@Override
46  		public String toConfigValue() {
47  			return configValue;
48  		}
49  
50  		@Override
51  		public boolean matchConfigValue(String s) {
52  			if (StringUtils.isEmptyOrNull(s)) {
53  				return false;
54  			}
55  			s = s.replace('-', '_');
56  			return name().equalsIgnoreCase(s)
57  					|| configValue.equalsIgnoreCase(s);
58  		}
59  	}
60  }