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

devonfw / IDEasy / 15389031315

02 Jun 2025 09:41AM UTC coverage: 67.675% (-0.06%) from 67.73%
15389031315

Pull #1341

github

web-flow
Merge 294b83a78 into cf09c6385
Pull Request #1341: #1340: Added error message if CWD and IDE_ROOT cases differ

3161 of 5078 branches covered (62.25%)

Branch coverage included in aggregate %.

8115 of 11584 relevant lines covered (70.05%)

3.07 hits per line

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

32.17
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.step.Step;
12
import com.devonfw.tools.ide.tool.IdeasyCommandlet;
13
import com.devonfw.tools.ide.variable.IdeVariables;
14
import com.devonfw.tools.ide.version.VersionIdentifier;
15

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

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

28
    super(context);
3✔
29
    addKeyword(getName());
4✔
30
  }
1✔
31

32
  @Override
33
  public String getName() {
34

35
    return "status";
2✔
36
  }
37

38
  @Override
39
  public void run() {
40
    Step step = this.context.newStep(true, "Show IDE_ROOT and IDE_HOME");
8✔
41
    step.run(this.context::logIdeHomeAndRootStatus);
9✔
42

43
    step = this.context.newStep(true, "Check CWD and IDE_ROOT path cases");
8✔
44
    step.run(this::checkCwdAndRootPathCases);
5✔
45

46
    step = this.context.newStep(true, "Show online status");
8✔
47
    step.run(this::logOnlineStatus);
5✔
48

49
    if (this.context.getIdeHome() != null) {
4!
50
      step = this.context.newStep(true, "Show git status");
×
51
      step.run(this::logSettingsGitStatus);
×
52
      step = this.context.newStep(true, "Show legacy status");
×
53
      step.run(this::logSettingsLegacyStatus);
×
54
      step = this.context.newStep(true, "Show migration status");
×
55
      step.run(this::logMigrationStatus);
×
56
    }
57
    step = this.context.newStep(true, "Check for updates of IDEasy");
8✔
58
    step.run(this::checkForUpdate);
5✔
59
  }
1✔
60

61
  private void checkCwdAndRootPathCases() {
62
    Path cwd = Path.of(System.getProperty("user.dir")).toAbsolutePath().normalize();
8✔
63
    Path root = Path.of(this.context.getSystem().getEnv(IdeVariables.IDE_ROOT.getName()))
×
64
        .toAbsolutePath().normalize();
×
65

66
    boolean isCaseSensitive;
67
    isCaseSensitive = !this.context.getSystemInfo().isLinux();
×
68

69
    boolean pathsMatch;
70

71
    if (isCaseSensitive) {
×
72
      pathsMatch = cwd.toString().startsWith(root.toString());
×
73
    } else {
74
      pathsMatch = cwd.toString().equalsIgnoreCase(root.toString());
×
75
    }
76

77
    if (!pathsMatch) {
×
78
      this.context.error(
×
79
          "Your CWD path: '{}' and your IDE_ROOT path: '{}' cases do not match!\n" +
80
              "Please check your 'user.dir' or starting directory and make sure that it matches your IDE_ROOT path.",
81
          cwd, root);
82
    }
83
  }
×
84

85
  private void checkForUpdate() {
86
    if (!this.context.isOnline()) {
4✔
87
      this.context.warning("Check for newer version of IDEasy is skipped due to no network connectivity.");
4✔
88
      return;
1✔
89
    }
90
    new IdeasyCommandlet(this.context, null).checkIfUpdateIsAvailable();
8✔
91
    logSystemInfo();
2✔
92
  }
1✔
93

94
  private void logSystemInfo() {
95
    SystemInfo systemInfo = this.context.getSystemInfo();
4✔
96
    this.context.info("Your operating system is {}({})@{} [{}@{}]", systemInfo.getOs(), systemInfo.getOsVersion(), systemInfo.getArchitecture(),
24✔
97
        systemInfo.getOsName(), systemInfo.getArchitectureName());
7✔
98
  }
1✔
99

100
  private void logSettingsLegacyStatus() {
101
    EnvironmentVariables variables = this.context.getVariables();
×
102
    boolean hasLegacyProperties = false;
×
103
    while (variables != null) {
×
104
      Path legacyProperties = variables.getLegacyPropertiesFilePath();
×
105
      if (legacyProperties != null && Files.exists(legacyProperties)) {
×
106
        hasLegacyProperties = true;
×
107
        this.context.warning("Found legacy properties {}", legacyProperties);
×
108
      }
109
      variables = variables.getParent();
×
110
    }
×
111
    if (hasLegacyProperties) {
×
112
      this.context.warning(
×
113
          "Your settings are outdated and contain legacy configurations. Please consider upgrading your settings:\nhttps://github.com/devonfw/IDEasy/blob/main/documentation/settings.adoc#upgrade");
114
    }
115
  }
×
116

117
  private void logSettingsGitStatus() {
118
    Path settingsPath = this.context.getSettingsGitRepository();
×
119
    if (settingsPath == null) {
×
120
      if (this.context.getIdeHome() != null) {
×
121
        this.context.error("No settings repository was found.");
×
122
      }
123
    } else {
124
      GitContext gitContext = this.context.getGitContext();
×
125
      if (gitContext.isRepositoryUpdateAvailable(settingsPath, this.context.getSettingsCommitIdPath())) {
×
126
        if (!this.context.isSettingsRepositorySymlinkOrJunction()) {
×
127
          this.context.warning("Your settings are not up-to-date, please run 'ide update'.");
×
128
        }
129
      } else {
130
        this.context.success("Your settings are up-to-date.");
×
131
      }
132
      String branch = gitContext.determineCurrentBranch(settingsPath);
×
133
      this.context.debug("Your settings branch is {}", branch);
×
134
      if (!"master".equals(branch) && !"main".equals(branch)) {
×
135
        this.context.warning("Your settings are on a custom branch: {}", branch);
×
136
      }
137
    }
138
  }
×
139

140
  private void logOnlineStatus() {
141
    if (this.context.isOfflineMode()) {
4!
142
      this.context.warning("You have configured offline mode via CLI.");
×
143
    } else if (this.context.isOnline()) {
4✔
144
      this.context.success("You are online.");
5✔
145
    } else {
146
      this.context.warning("You are offline. Check your internet connection and potential proxy settings.");
4✔
147
    }
148
  }
1✔
149

150
  private void logMigrationStatus() {
151

152
    IdeMigrator migrator = new IdeMigrator();
×
153
    VersionIdentifier projectVersion = this.context.getProjectVersion();
×
154
    VersionIdentifier targetVersion = migrator.getTargetVersion();
×
155
    if (projectVersion.isLess(targetVersion)) {
×
156
      this.context.interaction("Your project is on IDEasy version {} and needs an update to version {}!\nPlease run 'ide update' to migrate your project",
×
157
          projectVersion, targetVersion);
158
    }
159
  }
×
160

161
  @Override
162
  public boolean isIdeRootRequired() {
163

164
    return false;
2✔
165
  }
166
}
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