Skip to content

Conversation

Glavo
Copy link
Member

@Glavo Glavo commented Aug 4, 2025

No description provided.

@Glavo Glavo requested a review from Copilot August 13, 2025 12:49
Copy link
Contributor

@Copilot 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 PR optimizes the file renaming functionality after version updates by enhancing the pattern matching and introducing support for update channels in filename generation.

  • Refactored the tryRename method to support update channels and improved regex pattern matching
  • Enhanced the update application logic to rename files before copying and clean up old files
  • Added comprehensive test coverage for the new renaming functionality

Reviewed Changes

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

File Description
UpdateHandler.java Enhanced file renaming logic with channel support and improved update application flow
UpdateHandlerTest.java Added comprehensive test suite for the new file renaming functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


Matcher matcher = Pattern.compile(String.format(
"^(?<prefix>%s)(?<channel>%s)?(?<version>%s)(?<suffix>%s)$",
prefixPattern, channelPattern, versionPattern, suffixPattern))
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

[nitpick] The @regexp annotation is being used on local variables, but these are string literals that could be extracted as constants for better maintainability and reusability.

Suggested change
prefixPattern, channelPattern, versionPattern, suffixPattern))
Matcher matcher = Pattern.compile(String.format(
"^(?<prefix>%s)(?<channel>%s)?(?<version>%s)(?<suffix>%s)$",
PREFIX_PATTERN, CHANNEL_PATTERN, VERSION_PATTERN, SUFFIX_PATTERN))

Copilot uses AI. Check for mistakes.

Matcher matcher = Pattern.compile(String.format(
"^(?<prefix>%s)(?<channel>%s)?(?<version>%s)(?<suffix>%s)$",
prefixPattern, channelPattern, versionPattern, suffixPattern))
.matcher(fileName);
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

The Pattern.compile() call creates a new compiled pattern on every method invocation. Consider extracting this as a static final Pattern constant to avoid recompilation overhead.

Suggested change
.matcher(fileName);
Matcher matcher = HMCL_FILENAME_PATTERN.matcher(fileName);

Copilot uses AI. Check for mistakes.

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.

1 participant