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

devonfw / IDEasy / 12125578396

02 Dec 2024 06:25PM UTC coverage: 67.265% (+0.3%) from 67.008%
12125578396

push

github

web-flow
#824: fix git url with branch (#828)

2509 of 4080 branches covered (61.5%)

Branch coverage included in aggregate %.

6565 of 9410 relevant lines covered (69.77%)

3.08 hits per line

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

69.23
cli/src/main/java/com/devonfw/tools/ide/commandlet/RepositoryConfig.java
1
package com.devonfw.tools.ide.commandlet;
2

3
import java.io.FileInputStream;
4
import java.io.IOException;
5
import java.io.InputStream;
6
import java.nio.file.Path;
7
import java.util.Collections;
8
import java.util.Properties;
9
import java.util.Set;
10

11
import com.devonfw.tools.ide.git.GitUrl;
12

13
/**
14
 * Represents the configuration of a repository to be used by the {@link RepositoryCommandlet}.
15
 *
16
 * @param path Path into which the project is cloned. This path is relative to the workspace.
17
 * @param workingSets The working sets associated with the repository.
18
 * @param workspace Workspace to use for checkout and import. Default is main.
19
 * @param gitUrl Git URL to use for cloning the project.
20
 * @param gitBranch Git branch to checkout. Git default branch is default.
21
 * @param buildPath The build path for the repository.
22
 * @param buildCmd The command to invoke to build the repository after clone or pull. If omitted no build is triggered.
23
 * @param imports list of IDEs where the repository will be imported to.
24
 * @param active {@code true} to setup the repository during setup, {@code false} to skip.
25
 */
26
public record RepositoryConfig(
30✔
27
    String path,
28
    String workingSets,
29
    String workspace,
30
    String gitUrl,
31
    String gitBranch,
32
    String buildPath,
33
    String buildCmd,
34
    Set<String> imports,
35
    boolean active) {
36

37
  /**
38
   * @return the {@link GitUrl} from {@link #gitUrl()} and {@link #gitBranch()}.
39
   */
40
  public GitUrl asGitUrl() {
41

42
    return new GitUrl(this.gitUrl, this.gitBranch);
8✔
43
  }
44

45
  /**
46
   * @param filePath the {@link Path} to the {@link Properties} to load.
47
   * @return the parsed {@link RepositoryConfig}.
48
   */
49
  public static RepositoryConfig loadProperties(Path filePath) {
50

51
    Properties properties = new Properties();
4✔
52
    try (InputStream input = new FileInputStream(filePath.toString())) {
6✔
53
      properties.load(input);
3✔
54
    } catch (IOException e) {
×
55
      throw new IllegalStateException("Failed to read file: " + filePath, e);
×
56
    }
1✔
57

58
    Set<String> importsSet = getImports(properties);
3✔
59

60
    return new RepositoryConfig(properties.getProperty("path"), properties.getProperty("workingsets"),
11✔
61
        properties.getProperty("workspace"), properties.getProperty("git_url"), properties.getProperty("git_branch"),
9✔
62
        properties.getProperty(("build_path")), properties.getProperty("build_cmd"), importsSet,
7✔
63
        Boolean.parseBoolean(properties.getProperty("active").trim()));
4✔
64
  }
65

66
  private static Set<String> getImports(Properties properties) {
67

68
    String importProperty = properties.getProperty("import");
4✔
69
    if (importProperty != null && !importProperty.isEmpty()) {
2!
70
      return Set.of(importProperty.split("\\s*,\\s*"));
×
71
    }
72

73
    String legacyImportProperty = properties.getProperty("eclipse");
4✔
74
    if ("import".equals(legacyImportProperty)) {
4!
75
      return Set.of("eclipse");
×
76
    } else {
77
      return Collections.emptySet();
2✔
78
    }
79
  }
80
}
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