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

devonfw / IDEasy / 13210578415

08 Feb 2025 12:51AM UTC coverage: 68.205% (-0.2%) from 68.379%
13210578415

Pull #1021

github

web-flow
Merge cfb062251 into 9c2006bd8
Pull Request #1021: #786: support ide upgrade to automatically update to the latest version of IDEasy

2910 of 4683 branches covered (62.14%)

Branch coverage included in aggregate %.

7565 of 10675 relevant lines covered (70.87%)

3.09 hits per line

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

57.14
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.tool.IdeasyCommandlet;
10

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

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

23
    super(context);
3✔
24
    addKeyword(getName());
4✔
25
  }
1✔
26

27
  @Override
28
  public String getName() {
29

30
    return "status";
2✔
31
  }
32

33
  @Override
34
  public void run() {
35

36
    this.context.logIdeHomeAndRootStatus();
3✔
37
    logOnlineStatus();
2✔
38
    logSettingsGitStatus();
2✔
39
    logSettingsLegacyStatus();
2✔
40
    new IdeasyCommandlet(this.context, null).checkIfUpdateIsAvailable();
8✔
41
  }
1✔
42

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

60
  private void logSettingsGitStatus() {
61
    Path settingsPath = this.context.getSettingsGitRepository();
4✔
62
    if (settingsPath != null) {
2!
63
      GitContext gitContext = this.context.getGitContext();
×
64
      if (gitContext.isRepositoryUpdateAvailable(settingsPath, this.context.getSettingsCommitIdPath())) {
×
65
        if (!this.context.isSettingsRepositorySymlinkOrJunction()) {
×
66
          this.context.warning("Your settings are not up-to-date, please run 'ide update'.");
×
67
        }
68
      } else {
69
        this.context.success("Your settings are up-to-date.");
×
70
      }
71
      String branch = gitContext.determineCurrentBranch(settingsPath);
×
72
      this.context.debug("Your settings branch is {}", branch);
×
73
      if (!"master".equals(branch) && !"main".equals(branch)) {
×
74
        this.context.warning("Your settings are on a custom branch: {}", branch);
×
75
      }
76
    }
77
  }
1✔
78

79
  private void logOnlineStatus() {
80
    if (this.context.isOfflineMode()) {
4!
81
      this.context.warning("You have configured offline mode via CLI.");
×
82
    } else if (this.context.isOnline()) {
4!
83
      this.context.success("You are online.");
5✔
84
    } else {
85
      this.context.warning("You are offline. Check your internet connection and potential proxy settings.");
×
86
    }
87
  }
1✔
88

89
  @Override
90
  public boolean isIdeRootRequired() {
91

92
    return false;
2✔
93
  }
94
}
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