• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 19681245351

25 Nov 2025 07:13PM UTC coverage: 69.164% (+0.02%) from 69.147%
19681245351

Pull #1569

github

web-flow
Merge e3efba70a into ec798104b
Pull Request #1569: Add support for comma-separated workspace values in repository configuration

3650 of 5789 branches covered (63.05%)

Branch coverage included in aggregate %.

9476 of 13189 relevant lines covered (71.85%)

3.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

63.24
cli/src/main/java/com/devonfw/tools/ide/git/repository/RepositoryProperties.java
1
package com.devonfw.tools.ide.git.repository;
2

3
import java.nio.file.Path;
4
import java.util.Arrays;
5
import java.util.Properties;
6
import java.util.Set;
7
import java.util.stream.Collectors;
8

9
import com.devonfw.tools.ide.cli.CliException;
10
import com.devonfw.tools.ide.context.IdeContext;
11

12
/**
13
 * {@link Properties} for {@link RepositoryConfig}.
14
 */
15
final class RepositoryProperties {
16

17
  private final Path file;
18

19
  private final Properties properties;
20

21
  private final IdeContext context;
22

23
  /**
24
   * The constructor.
25
   *
26
   * @param file the {@link Path} to the properties file.
27
   * @param context the {@link IdeContext}.
28
   */
29
  public RepositoryProperties(Path file, IdeContext context) {
30
    this(file, context, context.getFileAccess().readProperties(file));
8✔
31
  }
1✔
32

33
  /**
34
   * @param file the {@link Path} to the properties file.
35
   * @param context the {@link IdeContext}.
36
   * @param properties the actual {@link Properties} loaded from the file.
37
   */
38
  RepositoryProperties(Path file, IdeContext context, Properties properties) {
39
    super();
2✔
40
    this.file = file;
3✔
41
    this.properties = properties;
3✔
42
    this.context = context;
3✔
43
  }
1✔
44

45
  /**
46
   * @param name the name of the requested property.
47
   * @return the value of the requested property or {@code null} if undefined.
48
   */
49
  public String getProperty(String name) {
50
    return getProperty(name, false);
5✔
51
  }
52

53
  /**
54
   * @param name the name of the requested property.
55
   * @param required - {@code true} if the requested property is required, {@code false} otherwise.
56
   * @return the value of the requested property or {@code null} if undefined.
57
   */
58
  public String getProperty(String name, boolean required) {
59

60
    String value = this.properties.getProperty(name);
5✔
61
    if (value == null) {
2!
62
      String legacyName = name.replace("_", ".");
×
63
      if (!legacyName.equals(name)) {
×
64
        value = getLegacyProperty(legacyName, name);
×
65
        if (value == null) {
×
66
          legacyName = name.replace("_", "-");
×
67
          value = getLegacyProperty(legacyName, name);
×
68
        }
69
      }
70
    }
71
    if (isEmpty(value)) {
3✔
72
      if (required) {
2✔
73
        throw new CliException("The properties file " + this.file + " must have a non-empty value for the required property " + name);
9✔
74
      }
75
      return null;
2✔
76
    }
77
    return value;
2✔
78
  }
79

80
  private static boolean isEmpty(String value) {
81

82
    return (value == null) || value.isBlank();
9!
83
  }
84

85
  private String getLegacyProperty(String legacyName, String name) {
86

87
    String value = this.properties.getProperty(legacyName);
5✔
88
    if (value != null) {
2!
89
      this.context.warning("The properties file {} uses the legacy property {} instead of {}", this.file, legacyName, name);
×
90
    }
91
    return value;
2✔
92
  }
93

94
  /**
95
   * @return the IDEs where to import the repository.
96
   */
97
  public Set<String> getImports() {
98

99
    String importProperty = this.properties.getProperty(RepositoryConfig.PROPERTY_IMPORT);
5✔
100
    if (importProperty != null) {
2!
101
      if (importProperty.isEmpty()) {
×
102
        return Set.of();
×
103
      }
104
      return Arrays.stream(importProperty.split(",")).map(String::trim).collect(Collectors.toUnmodifiableSet());
×
105
    }
106

107
    String legacyImportProperty = getLegacyProperty(RepositoryConfig.PROPERTY_ECLIPSE, RepositoryConfig.PROPERTY_IMPORT);
5✔
108
    if ("import".equals(legacyImportProperty)) {
4!
109
      this.context.warning("Property {} is deprecated and should be replaced with {} (invert key and value).", RepositoryConfig.PROPERTY_ECLIPSE,
×
110
          RepositoryConfig.PROPERTY_IMPORT);
111
      return Set.of("eclipse");
×
112
    } else {
113
      return Set.of();
2✔
114
    }
115
  }
116

117
  /**
118
   * @return the workspaces where to clone the repository. Returns a set containing "main" as default if not specified.
119
   */
120
  public Set<String> getWorkspaces() {
121

122
    String workspaceProperty = this.properties.getProperty(RepositoryConfig.PROPERTY_WORKSPACE);
5✔
123
    if (workspaceProperty != null) {
2!
124
      if (workspaceProperty.isEmpty()) {
3✔
125
        return Set.of(IdeContext.WORKSPACE_MAIN);
3✔
126
      }
127
      return Arrays.stream(workspaceProperty.split(",")).map(String::trim).collect(Collectors.toUnmodifiableSet());
10✔
128
    }
129
    return Set.of(IdeContext.WORKSPACE_MAIN);
×
130
  }
131

132
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc