Skip to content

创建 WindowsVersion 工具类#3932

Merged
Glavo merged 2 commits into
HMCL-dev:mainfrom
Glavo:os-version
May 23, 2025
Merged

创建 WindowsVersion 工具类#3932
Glavo merged 2 commits into
HMCL-dev:mainfrom
Glavo:os-version

Conversation

@Glavo
Copy link
Copy Markdown
Member

@Glavo Glavo commented May 23, 2025

No description provided.

@Glavo Glavo requested a review from Copilot May 23, 2025 12:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request creates a new WindowsVersion utility class to encapsulate Windows OS version details and updates the OperatingSystem class to make use of this new abstraction.

  • Adds a WindowsVersion class with constructors and utility methods for parsing and representing Windows versions.
  • Refactors OperatingSystem to use WindowsVersion for determining the OS version, replacing manual parsing and version comparison.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
HMCLCore/src/main/java/org/jackhuang/hmcl/util/platform/windows/WindowsVersion.java Introduces a dedicated class to represent Windows versions.
HMCLCore/src/main/java/org/jackhuang/hmcl/util/platform/OperatingSystem.java Refactors version handling by replacing string manipulation with WindowsVersion and updates OS version detection using its compareTo method.
Comments suppressed due to low confidence (1)

HMCLCore/src/main/java/org/jackhuang/hmcl/util/platform/OperatingSystem.java:177

  • The new regex pattern forces the version string to have exactly four segments; if the 'cmd ver' output sometimes contains only three segments, the version parsing will fail. Consider revising the regex to accept both three and four segment version strings.
Matcher matcher = Pattern.compile("(?<version>\d+\.\d+\.\d+\.\d+?)]$").matcher(reader.readLine().trim());

@Glavo Glavo merged commit 58a4700 into HMCL-dev:main May 23, 2025
2 checks passed
@Glavo Glavo deleted the os-version branch May 23, 2025 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants