Skip to content

#1255: Enhance snapshot version recognition in IDEasy#1962

Open
AdemZarrouki wants to merge 8 commits into
devonfw:mainfrom
AdemZarrouki:feature/1255-fix-snapshot-version-recognition
Open

#1255: Enhance snapshot version recognition in IDEasy#1962
AdemZarrouki wants to merge 8 commits into
devonfw:mainfrom
AdemZarrouki:feature/1255-fix-snapshot-version-recognition

Conversation

@AdemZarrouki
Copy link
Copy Markdown
Contributor

@AdemZarrouki AdemZarrouki commented May 21, 2026

This PR fixes #1255

Implemented changes:

  • Added isSameSnapshotVersion to compare 2 snapshot versions
  • Refactored checkIfUpdateIsAvailable with explicit snapshot vs stable version comparison logic

Testing instructions

  1. For the test i added some two unit tests testCheckIfUpdateIsAvailableWithSameSnapshotVersions and testCheckIfUpdateIsAvailableWithDifferentSnapshotVersions.
  2. It should be tested after the merge as with GraalVM, when running "C:\Users\projects\IDEasy\workspaces\main\IDEasy\cli\target\ideasy.exe" status you get only 2026.05.001-SNAPSHOT so we can't really compare it with the latest version (here 2026.05.001-20260520.032326-18)

Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat). If no issue ID exists, title only.
  • 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 or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labeled
    with internal
  • You have formulated clear instructions on how to test your contribution under "Testing instructions"

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented May 21, 2026

Coverage Report for CI Build 26283433836

Coverage increased (+0.006%) to 71.121%

Details

  • Coverage increased (+0.006%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 75 coverage regressions across 2 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

75 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
com/devonfw/tools/ide/tool/IdeasyCommandlet.java 74 73.15%
com/devonfw/tools/ide/version/VersionSegment.java 1 89.76%

Coverage Stats

Coverage Status
Relevant Lines: 15590
Covered Lines: 11567
Line Coverage: 74.19%
Relevant Branches: 6970
Covered Branches: 4478
Branch Coverage: 64.25%
Branches in Coverage %: Yes
Coverage Strength: 3.14 hits per line

💛 - Coveralls

@AdemZarrouki AdemZarrouki marked this pull request as ready for review May 21, 2026 14:30
@AdemZarrouki AdemZarrouki self-assigned this May 21, 2026
@AdemZarrouki AdemZarrouki added the status StatusCommandlet (ide status) label May 21, 2026
@AdemZarrouki AdemZarrouki moved this from 🆕 New to Team Review in IDEasy board May 21, 2026
Copy link
Copy Markdown
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

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

@AdemZarrouki thanks for your PR and sorry for stepping in early. I just found some time to have a look already and want to give fast feedback...
Your approach looks good and your test with overriding the methods in anonymous class is very elegant to properly test the logic. 👍
For the regex stuff I left some suggestion to improve.

Comment thread cli/src/main/java/com/devonfw/tools/ide/tool/IdeasyCommandlet.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/tool/IdeasyCommandlet.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/tool/IdeasyCommandletTest.java Outdated
}

// extract base year (YYYY)
Matcher baseMatcher_installed = Pattern.compile("^(\\d{4})\\.\\d{2}\\.\\d{3}$").matcher(base_installed);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As a best-practice we create Patterns as constants. This has the following advantages:

  • the pattern is compile only once (what takes some time even though it may be peanuts, in a server side app with millions of users this could make a difference) when the class is loaded and not every time the method gets executed
  • if the pattern has a syntax error you get fast fail behaviour and an exception will already be raised when the class is loaded and not only later when the method gets executed. Should not make much difference since you also cover the method in a JUnit test but if the regex breaks you would already get an exception if you run IDEasy but forget to run the test...
  • when we use groups, we even add a comment above to mark the group numbers so complex regular expressions get maintainable. See e.g. https://github.com/m-m-m/db/blob/c2b356923cf915ee6a1e13087f321b52fc494f95/schema/src/main/java/io/github/mmm/db/schema/impl/DbSchemaManagerImpl.java#L32-L34 (I was thinking or hoping that we follow these best-practices already in IDEasy but unfortunately not really yet - but it is never too late to improve the code style so for existing code I may find the time to do a cleanup PR on regex stuff).

I would simply create two REGEX constants one for the SNAPSHOT version pattern build into IDEasy and one for the maven/nexus SNAPSHOT version pattern for downloads.
Then you can compare the corresponding groups from both matchers in one go.
IMHO that would be easier to understand than having first two identical redundant regex patterns only for the base version and then additional regex patterns for the part after the dash.
WDYT?

@AdemZarrouki
Copy link
Copy Markdown
Contributor Author

@hohwille thanks for the early review and the improvements you mentioned. I updated the PR with the requested changes and also i think that using two REGEX constants is easier to understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status StatusCommandlet (ide status)

Projects

Status: Team Review

Development

Successfully merging this pull request may close these issues.

ide status does not recognize snapshot version correctly

4 participants