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

devonfw / IDEasy / 12995336297

27 Jan 2025 06:04PM UTC coverage: 68.45% (-0.05%) from 68.499%
12995336297

push

github

web-flow
#931: enhance settings in code repository (#983)

Co-authored-by: jan-vcapgemini <59438728+jan-vcapgemini@users.noreply.github.com>
Co-authored-by: Jörg Hohwiller <hohwille@users.noreply.github.com>

2793 of 4475 branches covered (62.41%)

Branch coverage included in aggregate %.

7211 of 10140 relevant lines covered (71.11%)

3.09 hits per line

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

56.45
cli/src/main/java/com/devonfw/tools/ide/commandlet/StatusCommandlet.java
1
package com.devonfw.tools.ide.commandlet;
2

3
import java.nio.file.Files;
4
import java.nio.file.Path;
5

6
import com.devonfw.tools.ide.context.IdeContext;
7
import com.devonfw.tools.ide.environment.EnvironmentVariables;
8
import com.devonfw.tools.ide.git.GitContext;
9

10
/**
11
 * {@link Commandlet} to print a status report about IDEasy.
12
 */
13
public class StatusCommandlet extends Commandlet {
14

15
  /**
16
   * The constructor.
17
   *
18
   * @param context the {@link IdeContext}.
19
   */
20
  public StatusCommandlet(IdeContext context) {
21

22
    super(context);
3✔
23
    addKeyword(getName());
4✔
24
  }
1✔
25

26
  @Override
27
  public String getName() {
28

29
    return "status";
2✔
30
  }
31

32
  @Override
33
  public void run() {
34

35
    this.context.logIdeHomeAndRootStatus();
3✔
36
    logOnlineStatus();
2✔
37
    logSettingsGitStatus();
2✔
38
    logSettingsLegacyStatus();
2✔
39
  }
1✔
40

41
  private void logSettingsLegacyStatus() {
42
    EnvironmentVariables variables = this.context.getVariables();
4✔
43
    boolean hasLegacyProperties = false;
2✔
44
    while (variables != null) {
2✔
45
      Path legacyProperties = variables.getLegacyPropertiesFilePath();
3✔
46
      if (legacyProperties != null && Files.exists(legacyProperties)) {
7!
47
        hasLegacyProperties = true;
×
48
        this.context.warning("Found legacy properties {}", legacyProperties);
×
49
      }
50
      variables = variables.getParent();
3✔
51
    }
1✔
52
    if (hasLegacyProperties) {
2!
53
      this.context.warning(
×
54
          "Your settings are outdated and contain legacy configurations. Please consider upgrading your settings:\nhttps://github.com/devonfw/IDEasy/blob/main/documentation/settings.adoc#upgrade");
55
    }
56
  }
1✔
57

58
  private void logSettingsGitStatus() {
59
    Path settingsPath = this.context.getSettingsGitRepository();
4✔
60
    if (settingsPath != null) {
2!
61
      GitContext gitContext = this.context.getGitContext();
×
62
      if (gitContext.isRepositoryUpdateAvailable(settingsPath, this.context.getSettingsCommitIdPath())) {
×
63
        if (!this.context.isSettingsRepositorySymlinkOrJunction()) {
×
64
          this.context.warning("Your settings are not up-to-date, please run 'ide update'.");
×
65
        }
66
      } else {
67
        this.context.success("Your settings are up-to-date.");
×
68
      }
69
      String branch = gitContext.determineCurrentBranch(settingsPath);
×
70
      this.context.debug("Your settings branch is {}", branch);
×
71
      if (!"master".equals(branch) && !"main".equals(branch)) {
×
72
        this.context.warning("Your settings are on a custom branch: {}", branch);
×
73
      }
74
    }
75
  }
1✔
76

77
  private void logOnlineStatus() {
78
    if (this.context.isOfflineMode()) {
4!
79
      this.context.warning("You have configured offline mode via CLI.");
×
80
    } else if (this.context.isOnline()) {
4!
81
      this.context.success("You are online.");
5✔
82
    } else {
83
      this.context.warning("You are offline. Check your internet connection and potential proxy settings.");
×
84
    }
85
  }
1✔
86

87
  @Override
88
  public boolean isIdeRootRequired() {
89

90
    return false;
2✔
91
  }
92
}
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