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

devonfw / IDEasy / 13968888267

20 Mar 2025 12:06PM UTC coverage: 67.667% (+0.01%) from 67.657%
13968888267

push

github

web-flow
#1153: print os info in status (#1154)

3036 of 4915 branches covered (61.77%)

Branch coverage included in aggregate %.

7830 of 11143 relevant lines covered (70.27%)

3.07 hits per line

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

26.19
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
import com.devonfw.tools.ide.migration.IdeMigrator;
10
import com.devonfw.tools.ide.os.SystemInfo;
11
import com.devonfw.tools.ide.tool.IdeasyCommandlet;
12
import com.devonfw.tools.ide.version.VersionIdentifier;
13

14
/**
15
 * {@link Commandlet} to print a status report about IDEasy.
16
 */
17
public class StatusCommandlet extends Commandlet {
18

19
  /**
20
   * The constructor.
21
   *
22
   * @param context the {@link IdeContext}.
23
   */
24
  public StatusCommandlet(IdeContext context) {
25

26
    super(context);
3✔
27
    addKeyword(getName());
4✔
28
  }
1✔
29

30
  @Override
31
  public String getName() {
32

33
    return "status";
2✔
34
  }
35

36
  @Override
37
  public void run() {
38

39
    this.context.logIdeHomeAndRootStatus();
3✔
40
    logOnlineStatus();
2✔
41
    if (this.context.getIdeHome() != null) {
4!
42
      logSettingsGitStatus();
×
43
      logSettingsLegacyStatus();
×
44
      logMigrationStatus();
×
45
    }
46
    new IdeasyCommandlet(this.context, null).checkIfUpdateIsAvailable();
8✔
47
    logSystemInfo();
2✔
48
  }
1✔
49

50
  private void logSystemInfo() {
51
    SystemInfo systemInfo = this.context.getSystemInfo();
4✔
52
    this.context.info("Your operating system is {}({})@{} [{}@{}]", systemInfo.getOs(), systemInfo.getOsVersion(), systemInfo.getArchitecture(),
24✔
53
        systemInfo.getOsName(), systemInfo.getArchitectureName());
7✔
54
  }
1✔
55

56
  private void logSettingsLegacyStatus() {
57
    EnvironmentVariables variables = this.context.getVariables();
×
58
    boolean hasLegacyProperties = false;
×
59
    while (variables != null) {
×
60
      Path legacyProperties = variables.getLegacyPropertiesFilePath();
×
61
      if (legacyProperties != null && Files.exists(legacyProperties)) {
×
62
        hasLegacyProperties = true;
×
63
        this.context.warning("Found legacy properties {}", legacyProperties);
×
64
      }
65
      variables = variables.getParent();
×
66
    }
×
67
    if (hasLegacyProperties) {
×
68
      this.context.warning(
×
69
          "Your settings are outdated and contain legacy configurations. Please consider upgrading your settings:\nhttps://github.com/devonfw/IDEasy/blob/main/documentation/settings.adoc#upgrade");
70
    }
71
  }
×
72

73
  private void logSettingsGitStatus() {
74
    Path settingsPath = this.context.getSettingsGitRepository();
×
75
    if (settingsPath == null) {
×
76
      if (this.context.getIdeHome() != null) {
×
77
        this.context.error("No settings repository was found.");
×
78
      }
79
    } else {
80
      GitContext gitContext = this.context.getGitContext();
×
81
      if (gitContext.isRepositoryUpdateAvailable(settingsPath, this.context.getSettingsCommitIdPath())) {
×
82
        if (!this.context.isSettingsRepositorySymlinkOrJunction()) {
×
83
          this.context.warning("Your settings are not up-to-date, please run 'ide update'.");
×
84
        }
85
      } else {
86
        this.context.success("Your settings are up-to-date.");
×
87
      }
88
      String branch = gitContext.determineCurrentBranch(settingsPath);
×
89
      this.context.debug("Your settings branch is {}", branch);
×
90
      if (!"master".equals(branch) && !"main".equals(branch)) {
×
91
        this.context.warning("Your settings are on a custom branch: {}", branch);
×
92
      }
93
    }
94
  }
×
95

96
  private void logOnlineStatus() {
97
    if (this.context.isOfflineMode()) {
4!
98
      this.context.warning("You have configured offline mode via CLI.");
×
99
    } else if (this.context.isOnline()) {
4!
100
      this.context.success("You are online.");
5✔
101
    } else {
102
      this.context.warning("You are offline. Check your internet connection and potential proxy settings.");
×
103
    }
104
  }
1✔
105

106
  private void logMigrationStatus() {
107

108
    IdeMigrator migrator = new IdeMigrator();
×
109
    VersionIdentifier projectVersion = this.context.getProjectVersion();
×
110
    VersionIdentifier targetVersion = migrator.getTargetVersion();
×
111
    if (projectVersion.isLess(targetVersion)) {
×
112
      this.context.interaction("Your project is on IDEasy version {} and needs an update to version {}!\nPlease run 'ide update' to migrate your project",
×
113
          projectVersion, targetVersion);
114
    }
115
  }
×
116

117
  @Override
118
  public boolean isIdeRootRequired() {
119

120
    return false;
2✔
121
  }
122
}
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