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

devonfw / IDEasy / 13987530229

21 Mar 2025 08:22AM UTC coverage: 67.688% (+0.01%) from 67.674%
13987530229

push

github

web-flow
#1110: Fixed ide status fails with IllegalStateException when being offline (#1125)

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

3038 of 4916 branches covered (61.8%)

Branch coverage included in aggregate %.

7830 of 11140 relevant lines covered (70.29%)

3.07 hits per line

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

34.07
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
    checkForUpdate();
2✔
47
  }
1✔
48

49
  private void checkForUpdate() {
50
    if (!this.context.isOnline()) {
4✔
51
      this.context.warning("Check for newer version of IDEasy is skipped due to no network connectivity.");
4✔
52
      return;
1✔
53
    }
54
    new IdeasyCommandlet(this.context, null).checkIfUpdateIsAvailable();
8✔
55
    logSystemInfo();
2✔
56
  }
1✔
57

58
  private void logSystemInfo() {
59
    SystemInfo systemInfo = this.context.getSystemInfo();
4✔
60
    this.context.info("Your operating system is {}({})@{} [{}@{}]", systemInfo.getOs(), systemInfo.getOsVersion(), systemInfo.getArchitecture(),
24✔
61
        systemInfo.getOsName(), systemInfo.getArchitectureName());
7✔
62
  }
1✔
63

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

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

104
  private void logOnlineStatus() {
105
    if (this.context.isOfflineMode()) {
4!
106
      this.context.warning("You have configured offline mode via CLI.");
×
107
    } else if (this.context.isOnline()) {
4✔
108
      this.context.success("You are online.");
5✔
109
    } else {
110
      this.context.warning("You are offline. Check your internet connection and potential proxy settings.");
4✔
111
    }
112
  }
1✔
113

114
  private void logMigrationStatus() {
115

116
    IdeMigrator migrator = new IdeMigrator();
×
117
    VersionIdentifier projectVersion = this.context.getProjectVersion();
×
118
    VersionIdentifier targetVersion = migrator.getTargetVersion();
×
119
    if (projectVersion.isLess(targetVersion)) {
×
120
      this.context.interaction("Your project is on IDEasy version {} and needs an update to version {}!\nPlease run 'ide update' to migrate your project",
×
121
          projectVersion, targetVersion);
122
    }
123
  }
×
124

125
  @Override
126
  public boolean isIdeRootRequired() {
127

128
    return false;
2✔
129
  }
130
}
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