-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: skip stable update prompt for newer prereleases #9071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -234,13 +234,24 @@ def compare_version(self, v1: str, v2: str) -> int: | |
| """Semver 版本比较""" | ||
| return VersionComparator.compare_version(v1, v2) | ||
|
|
||
| def _is_prerelease_version(self, version: str) -> bool: | ||
| """Check if a version string is a prerelease version.""" | ||
| return bool( | ||
| re.search( | ||
| r"[\-_.]?(alpha|beta|rc|dev)[\-_.]?\d*$", | ||
| version, | ||
| re.IGNORECASE, | ||
| ) | ||
| ) | ||
|
|
||
| async def check_update( | ||
| self, | ||
| url: str, | ||
| current_version: str, | ||
| consider_prerelease: bool = True, | ||
| ) -> ReleaseInfo | None: | ||
| update_data = await self.fetch_release_info(url) | ||
| current_is_prerelease = self._is_prerelease_version(current_version) | ||
|
|
||
| sel_release_data = None | ||
| if consider_prerelease: | ||
|
|
@@ -249,11 +260,7 @@ async def check_update( | |
| else: | ||
| for data in update_data: | ||
| # 跳过带有 alpha、beta 等预发布标签的版本 | ||
| if re.search( | ||
| r"[\-_.]?(alpha|beta|rc|dev)[\-_.]?\d*$", | ||
| data["tag_name"], | ||
| re.IGNORECASE, | ||
| ): | ||
| if self._is_prerelease_version(data["tag_name"]): | ||
| continue | ||
| tag_name = data["tag_name"] | ||
| sel_release_data = data | ||
|
|
@@ -263,6 +270,10 @@ async def check_update( | |
| logger.error("未找到合适的发布版本") | ||
| return None | ||
|
|
||
| if current_is_prerelease and not self._is_prerelease_version(tag_name): | ||
| if self.compare_version(current_version, tag_name) >= 0: | ||
|
Comment on lines
+273
to
+274
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: The prerelease-specific guard appears redundant with the general version comparison below. If |
||
| return None | ||
|
|
||
|
Comment on lines
+273
to
+276
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This conditional block is completely redundant and can be safely removed. Why is it redundant?
Version Comparison BehaviorIn Removing this block simplifies the logic and improves maintainability. Please also remove the unused |
||
| if self.compare_version(current_version, tag_name) >= 0: | ||
| return None | ||
| return ReleaseInfo( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the redundant block on lines 273-275 is removed, the
current_is_prereleasevariable becomes unused. Removing it prevents potential linter warnings (such as Ruff'sF841).