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

devonfw / IDEasy / 11783359749

11 Nov 2024 05:30PM UTC coverage: 67.195% (+0.06%) from 67.136%
11783359749

push

github

web-flow
#312: Added ability to prefer git (ssh) protocol instead of https for cloning repos (#724)

2444 of 3981 branches covered (61.39%)

Branch coverage included in aggregate %.

6376 of 9145 relevant lines covered (69.72%)

3.07 hits per line

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

64.29
cli/src/main/java/com/devonfw/tools/ide/context/GitUrl.java
1
package com.devonfw.tools.ide.context;
2

3
import java.net.MalformedURLException;
4
import java.net.URL;
5

6
/**
7
 * Handles parsing of git URLs.
8
 *
9
 * @param url the git url e.g. https://github.com/devonfw/ide-urls.git.
10
 * @param branch the branch name e.g. master.
11
 */
12
public record GitUrl(String url, String branch) {
9✔
13

14
  /**
15
   * Converts the Git URL based on the specified {@link GitUrlSyntax}.
16
   *
17
   * @param syntax the preferred {@link GitUrlSyntax} (SSH or HTTPS).
18
   * @return the converted {@link GitUrl} or the original if no conversion is required.
19
   */
20
  public GitUrl convert(GitUrlSyntax syntax) {
21
    return syntax.format(this);
4✔
22
  }
23

24
  /**
25
   * Parses a git URL and omits the branch name if not provided.
26
   *
27
   * @return parsed URL.
28
   */
29
  public URL parseUrl() {
30

31
    String parsedUrl = this.url;
3✔
32
    if (this.branch != null && !this.branch.isEmpty()) {
7!
33
      parsedUrl += "#" + this.branch;
×
34
    }
35
    URL validUrl;
36
    try {
37
      validUrl = new URL(parsedUrl);
5✔
38
    } catch (MalformedURLException e) {
×
39
      throw new RuntimeException("Git URL is not valid " + parsedUrl, e);
×
40
    }
1✔
41
    return validUrl;
2✔
42
  }
43
}
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