Skip to content

#2296: Refactor ToolCommandlet to determine InstalledEdition and Version in a Single Cached Lookup - #2306

Open
krystynaShatkovska wants to merge 1 commit into
devonfw:mainfrom
krystynaShatkovska:feature/issue-2296
Open

#2296: Refactor ToolCommandlet to determine InstalledEdition and Version in a Single Cached Lookup#2306
krystynaShatkovska wants to merge 1 commit into
devonfw:mainfrom
krystynaShatkovska:feature/issue-2296

Conversation

@krystynaShatkovska

@krystynaShatkovska krystynaShatkovska commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Implemented changes:

This PR refactors the way IDEasy determines the installed edition and version of tools. Previously, getInstalledEdition() and getInstalledVersion() were separate methods
that often performed redundant expensive lookups (registry queries, process execution, etc.). The new combined approach computes both values in a single call.

  • Introduced the record EditionAndVersion(String edition, VersionIdentifier version) to hold both values together
  • Added getInstalledEditionAndVersion() with CachedValue to ToolCommandlet — delegates to computeInstalledEditionAndVersion()
  • Made getInstalledVersion() and getInstalledEdition() final — they now delegate to the combined method
  • Implemented computeInstalledEditionAndVersion() in LocalToolCommandlet (resolves edition + version via software link target)
  • GlobalToolCommandlet: getWindowsRegistryAppNames() returns Map<String, String> mapping edition → registry app name
  • Docker: returns Map.of(\"docker\", \"Docker Desktop\", \"rancher\", \"Rancher Desktop\") — enabling correct detection of Rancher Desktop edition
  • Implemented computeInstalledEditionAndVersion() in LocalToolCommandlet (resolves edition + version via software link target)
  • GlobalToolCommandlet: getWindowsRegistryAppNames() returns Map<String, String> mapping edition → registry app name
  • Docker: returns Map.of(\"docker\", \"Docker Desktop\", \"rancher\", \"Rancher Desktop\") — enabling correct detection of Rancher Desktop edition
  • Updated all relevant subclasses (IdeasyCommandlet, KubeCtl, DelegatingToolCommandlet, PackageManagerBasedLocalToolCommandlet, NodeBasedCommandlet)
  • Added cache invalidation after installation via invalidateInstalledEditionAndVersion()
  • Fixed pre-existing GUI compilation issue (IdeContext.findProjects was package-private instead of public)

Backward compatibility is maintained via deprecated hooks (computeInstalledEdition(), computeInstalledVersion(), getInstalledVersionDeprecated(),
getInstalledEditionDeprecated()).


Testing instructions

  1. Run `mvn clean test` — all 901 tests (CLI: 845, GUI: 56) pass with BUILD SUCCESS
  2. Test Docker edition detection: install Rancher Desktop and run `ideasy docker info` — should correctly report edition as "rancher" instead of "docker"
  3. Test global tool detection on Windows: run `ideasy docker install` and verify the registry lookup correctly identifies the installed edition

Checklist for this PR

  • When running `mvn clean test` locally all tests pass and build is successful
  • PR title is of the form `#«issue-id»: «brief summary»`
  • PR top-level comment summarizes what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to `In Progress` and assigned to you
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc
  • You have not changed any dependency in `pom.xml` files
  • You have formulated clear instructions on how to test your contribution under "Testing instructions"" 2>&1

@github-project-automation github-project-automation Bot moved this to 🆕 New in IDEasy board Aug 11, 2026
@krystynaShatkovska krystynaShatkovska self-assigned this Aug 11, 2026
@krystynaShatkovska krystynaShatkovska added enhancement New feature or request core FileAccess, ProcessUtil, IdeContext, etc. ready-to-implement labels Aug 11, 2026
@krystynaShatkovska krystynaShatkovska moved this from 🆕 New to Team Review in IDEasy board Aug 11, 2026
@krystynaShatkovska krystynaShatkovska changed the title Feature/issue 2296 #2296: Refactor ToolCommandlet to determine InstalledEdition and Version in a Single Cached Lookup Aug 11, 2026
@laert-ll laert-ll self-assigned this Aug 11, 2026
@coveralls

coveralls commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 32020213701

Warning

No base build found for commit 31dabbf on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 73.056%

Details

  • Patch coverage: No coverable lines changed in this PR.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 17578
Covered Lines: 13391
Line Coverage: 76.18%
Relevant Branches: 7778
Covered Branches: 5133
Branch Coverage: 65.99%
Branches in Coverage %: Yes
Coverage Strength: 3.24 hits per line

💛 - Coveralls

@laert-ll laert-ll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work! The overall direction is nice, and the EditionAndVersion with a single cached lookup is exactly what the issue was after. I've left a few inline comments on some details that need some improvement.

The main thing I noticed is that the branch seems to accidentally include some unrelated work (the GUI changes from #2278 and some changelog changes as well). Make sure to rebase to main to clean this up and fix the merge conflicts. Apart from that I would also suggest adding some tests for this.

Other than that, thanks for your contribution again!

Comment thread CHANGELOG.adoc
Comment thread cli/src/main/java/com/devonfw/tools/ide/tool/kubectl/KubeCtl.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/tool/ToolCommandlet.java
Comment thread cli/src/main/java/com/devonfw/tools/ide/tool/docker/Docker.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/tool/kubectl/KubeCtl.java Outdated
@krystynaShatkovska krystynaShatkovska moved this from 👀 In review to Team Review in IDEasy board Aug 17, 2026
)

Introduce EditionAndVersion to resolve a tool's installed edition and
version in a single cached lookup, with a protected
computeInstalledEditionAndVersion() hook.

- KubeCtl: read version from 'kubectl version --client' and route through
  the public getInstalledEditionAndVersion() override so it is actually
  used; add KubeCtlTest.
- LocalToolCommandlet: resolve edition and version in one tool-path lookup.
- Docker: keep the resolved edition consistent ('docker'/'rancher') across
  all OSes instead of the bogus 'desktop'; detect the Docker Desktop
  version on macOS from the Docker.app bundle; add DockerTest.
- CHANGELOG: add devonfw#2296 line under 2026.08.002.

Rebased onto upstream/main (drops unrelated devonfw#2278 work).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core FileAccess, ProcessUtil, IdeContext, etc. enhancement New feature or request ready-to-implement

Projects

Status: Team Review

Development

Successfully merging this pull request may close these issues.

3 participants