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

devonfw / IDEasy / 13344877458

15 Feb 2025 12:10PM UTC coverage: 67.959% (-0.5%) from 68.482%
13344877458

Pull #1021

github

web-flow
Merge 3118dedf4 into c70643978
Pull Request #1021: #786: support ide upgrade to automatically update to the latest version of IDEasy

2966 of 4793 branches covered (61.88%)

Branch coverage included in aggregate %.

7690 of 10887 relevant lines covered (70.63%)

3.07 hits per line

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

20.25
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.tool.IdeasyCommandlet;
11
import com.devonfw.tools.ide.version.VersionIdentifier;
12

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

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

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

29
  @Override
30
  public String getName() {
31

32
    return "status";
2✔
33
  }
34

35
  @Override
36
  public void run() {
37

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

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

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

88
  private void logOnlineStatus() {
89
    if (this.context.isOfflineMode()) {
4!
90
      this.context.warning("You have configured offline mode via CLI.");
×
91
    } else if (this.context.isOnline()) {
4!
92
      this.context.success("You are online.");
5✔
93
    } else {
94
      this.context.warning("You are offline. Check your internet connection and potential proxy settings.");
×
95
    }
96
  }
1✔
97

98
  private void logMigrationStatus() {
99

100
    IdeMigrator migrator = new IdeMigrator();
×
101
    VersionIdentifier projectVersion = this.context.getProjectVersion();
×
102
    VersionIdentifier targetVersion = migrator.getTargetVersion();
×
103
    if (projectVersion.isLess(targetVersion)) {
×
104
      this.context.interaction("Your project is on IDEasy version {} and needs an update to version {}!\nPlease run 'ide update' to migrate your project",
×
105
          projectVersion, targetVersion);
106
    }
107
  }
×
108

109
  @Override
110
  public boolean isIdeRootRequired() {
111

112
    return false;
2✔
113
  }
114
}
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