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

devonfw / IDEasy / 14646736541

24 Apr 2025 04:30PM UTC coverage: 68.713% (+1.3%) from 67.429%
14646736541

push

github

web-flow
#1243: Fix logging of ide status although errors might occur (#1247)

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

2425 of 4000 branches covered (60.62%)

Branch coverage included in aggregate %.

6729 of 9322 relevant lines covered (72.18%)

3.72 hits per line

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

35.05
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.version.VersionIdentifier;
14

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

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

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

31
  @Override
32
  public String getName() {
33

34
    return "status";
2✔
35
  }
36

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

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

56
  private void checkForUpdate() {
57
    if (!this.context.isOnline()) {
4✔
58
      this.context.warning("Check for newer version of IDEasy is skipped due to no network connectivity.");
4✔
59
      return;
1✔
60
    }
61
    new IdeasyCommandlet(this.context, null).checkIfUpdateIsAvailable();
8✔
62
    logSystemInfo();
2✔
63
  }
1✔
64

65
  private void logSystemInfo() {
66
    SystemInfo systemInfo = this.context.getSystemInfo();
4✔
67
    this.context.info("Your operating system is {}({})@{} [{}@{}]", systemInfo.getOs(), systemInfo.getOsVersion(), systemInfo.getArchitecture(),
24✔
68
        systemInfo.getOsName(), systemInfo.getArchitectureName());
7✔
69
  }
1✔
70

71
  private void logSettingsLegacyStatus() {
72
    EnvironmentVariables variables = this.context.getVariables();
×
73
    boolean hasLegacyProperties = false;
×
74
    while (variables != null) {
×
75
      Path legacyProperties = variables.getLegacyPropertiesFilePath();
×
76
      if (legacyProperties != null && Files.exists(legacyProperties)) {
×
77
        hasLegacyProperties = true;
×
78
        this.context.warning("Found legacy properties {}", legacyProperties);
×
79
      }
80
      variables = variables.getParent();
×
81
    }
×
82
    if (hasLegacyProperties) {
×
83
      this.context.warning(
×
84
          "Your settings are outdated and contain legacy configurations. Please consider upgrading your settings:\nhttps://github.com/devonfw/IDEasy/blob/main/documentation/settings.adoc#upgrade");
85
    }
86
  }
×
87

88
  private void logSettingsGitStatus() {
89
    Path settingsPath = this.context.getSettingsGitRepository();
×
90
    if (settingsPath == null) {
×
91
      if (this.context.getIdeHome() != null) {
×
92
        this.context.error("No settings repository was found.");
×
93
      }
94
    } else {
95
      GitContext gitContext = this.context.getGitContext();
×
96
      if (gitContext.isRepositoryUpdateAvailable(settingsPath, this.context.getSettingsCommitIdPath())) {
×
97
        if (!this.context.isSettingsRepositorySymlinkOrJunction()) {
×
98
          this.context.warning("Your settings are not up-to-date, please run 'ide update'.");
×
99
        }
100
      } else {
101
        this.context.success("Your settings are up-to-date.");
×
102
      }
103
      String branch = gitContext.determineCurrentBranch(settingsPath);
×
104
      this.context.debug("Your settings branch is {}", branch);
×
105
      if (!"master".equals(branch) && !"main".equals(branch)) {
×
106
        this.context.warning("Your settings are on a custom branch: {}", branch);
×
107
      }
108
    }
109
  }
×
110

111
  private void logOnlineStatus() {
112
    if (this.context.isOfflineMode()) {
4!
113
      this.context.warning("You have configured offline mode via CLI.");
×
114
    } else if (this.context.isOnline()) {
4✔
115
      this.context.success("You are online.");
5✔
116
    } else {
117
      this.context.warning("You are offline. Check your internet connection and potential proxy settings.");
4✔
118
    }
119
  }
1✔
120

121
  private void logMigrationStatus() {
122

123
    IdeMigrator migrator = new IdeMigrator();
×
124
    VersionIdentifier projectVersion = this.context.getProjectVersion();
×
125
    VersionIdentifier targetVersion = migrator.getTargetVersion();
×
126
    if (projectVersion.isLess(targetVersion)) {
×
127
      this.context.interaction("Your project is on IDEasy version {} and needs an update to version {}!\nPlease run 'ide update' to migrate your project",
×
128
          projectVersion, targetVersion);
129
    }
130
  }
×
131

132
  @Override
133
  public boolean isIdeRootRequired() {
134

135
    return false;
2✔
136
  }
137
}
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