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

devonfw / IDEasy / 22300285724

23 Feb 2026 09:32AM UTC coverage: 70.754% (+0.3%) from 70.474%
22300285724

Pull #1714

github

web-flow
Merge caa980897 into 379acdc9d
Pull Request #1714: #404: #1713: advanced logging

4064 of 6348 branches covered (64.02%)

Branch coverage included in aggregate %.

10640 of 14434 relevant lines covered (73.71%)

3.1 hits per line

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

88.37
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.ArrayList;
5
import java.util.Arrays;
6
import java.util.Collections;
7
import java.util.HashSet;
8
import java.util.List;
9
import java.util.Properties;
10
import java.util.Set;
11
import java.util.stream.Collectors;
12

13
import org.slf4j.Logger;
14
import org.slf4j.LoggerFactory;
15

16
import com.devonfw.tools.ide.cli.CliException;
17
import com.devonfw.tools.ide.context.IdeContext;
18

19
/**
20
 * {@link Properties} for {@link RepositoryConfig}.
21
 */
22
final class RepositoryProperties {
23

24
  private static final Logger LOG = LoggerFactory.getLogger(RepositoryProperties.class);
4✔
25

26
  private final Path file;
27

28
  private final Properties properties;
29

30
  /**
31
   * The constructor.
32
   *
33
   * @param file the {@link Path} to the properties file.
34
   * @param context the {@link IdeContext}.
35
   */
36
  public RepositoryProperties(Path file, IdeContext context) {
37
    this(file, context.getFileAccess().readProperties(file));
7✔
38
  }
1✔
39

40
  /**
41
   * @param file the {@link Path} to the properties file.
42
   * @param properties the actual {@link Properties} loaded from the file.
43
   */
44
  RepositoryProperties(Path file, Properties properties) {
45
    super();
2✔
46
    this.file = file;
3✔
47
    this.properties = properties;
3✔
48
  }
1✔
49

50
  /**
51
   * @param name the name of the requested property.
52
   * @return the value of the requested property or {@code null} if undefined.
53
   */
54
  public String getProperty(String name) {
55
    return getProperty(name, false);
5✔
56
  }
57

58
  /**
59
   * @param name the name of the requested property.
60
   * @param required - {@code true} if the requested property is required, {@code false} otherwise.
61
   * @return the value of the requested property or {@code null} if undefined.
62
   */
63
  public String getProperty(String name, boolean required) {
64

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

85
  private static boolean isEmpty(String value) {
86

87
    return (value == null) || value.isBlank();
9✔
88
  }
89

90
  private String getLegacyProperty(String legacyName, String name) {
91

92
    String value = this.properties.getProperty(legacyName);
5✔
93
    if (value != null) {
2!
94
      LOG.warn("The properties file {} uses the legacy property {} instead of {}", this.file, legacyName, name);
×
95
    }
96
    return value;
2✔
97
  }
98

99
  /**
100
   * @return the IDEs where to import the repository.
101
   */
102
  public Set<String> getImports() {
103

104
    String importProperty = this.properties.getProperty(RepositoryConfig.PROPERTY_IMPORT);
5✔
105
    if (importProperty != null) {
2✔
106
      if (importProperty.isEmpty()) {
3!
107
        return Set.of();
×
108
      }
109
      return Arrays.stream(importProperty.split(",")).map(String::trim).collect(Collectors.toUnmodifiableSet());
10✔
110
    }
111

112
    String legacyImportProperty = getLegacyProperty(RepositoryConfig.PROPERTY_ECLIPSE, RepositoryConfig.PROPERTY_IMPORT);
5✔
113
    if ("import".equals(legacyImportProperty)) {
4!
114
      LOG.warn("Property {} is deprecated and should be replaced with {} (invert key and value).", RepositoryConfig.PROPERTY_ECLIPSE,
×
115
          RepositoryConfig.PROPERTY_IMPORT);
116
      return Set.of("eclipse");
×
117
    } else {
118
      return Set.of();
2✔
119
    }
120
  }
121

122
  /**
123
   * @return the workspaces where to clone the repository. Returns a set containing "main" as default if not specified.
124
   */
125
  public List<String> getWorkspaces() {
126

127
    String workspaceProperty = this.properties.getProperty(RepositoryConfig.PROPERTY_WORKSPACES);
5✔
128
    if (workspaceProperty == null) {
2✔
129
      workspaceProperty = this.properties.getProperty("workspace");
5✔
130
      if (workspaceProperty != null) {
2✔
131
        LOG.debug("Property workspace is legacy, please change property name to workspaces in {}", this.file);
5✔
132
      }
133
    }
134
    if ((workspaceProperty != null) && !workspaceProperty.isEmpty()) {
5✔
135
      List<String> list = new ArrayList<>();
4✔
136
      Set<String> set = new HashSet<>();
4✔
137
      for (String workspace : workspaceProperty.split(",")) {
18✔
138
        workspace = workspace.trim();
3✔
139
        boolean added = set.add(workspace);
4✔
140
        if (added) {
2!
141
          list.add(workspace);
5✔
142
        } else {
143
          LOG.warn("Ignoring duplicate workspace {} from {}", workspace, workspaceProperty);
×
144
        }
145
      }
146
      return Collections.unmodifiableList(list);
3✔
147
    }
148
    return List.of(IdeContext.WORKSPACE_MAIN);
3✔
149
  }
150

151
}
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

© 2026 Coveralls, Inc