🤖 自动格式化代码 [skip ci]
This commit is contained in:
@@ -34,7 +34,6 @@ class VersionComparator:
|
||||
"0.8.7": ["0.8.8", "0.8.9", "0.8.10"],
|
||||
"0.8.8": ["0.8.9", "0.8.10"],
|
||||
"0.8.9": ["0.8.10"],
|
||||
|
||||
# 可以根据需要添加更多兼容映射
|
||||
# "0.9.0": ["0.9.1", "0.9.2", "0.9.3"], # 示例:0.9.x系列兼容
|
||||
}
|
||||
@@ -110,23 +109,23 @@ class VersionComparator:
|
||||
@staticmethod
|
||||
def check_forward_compatibility(current_version: str, max_version: str) -> Tuple[bool, str]:
|
||||
"""检查向前兼容性(仅使用兼容性映射表)
|
||||
|
||||
|
||||
Args:
|
||||
current_version: 当前版本
|
||||
max_version: 插件声明的最大支持版本
|
||||
|
||||
|
||||
Returns:
|
||||
Tuple[bool, str]: (是否兼容, 兼容信息)
|
||||
"""
|
||||
current_normalized = VersionComparator.normalize_version(current_version)
|
||||
max_normalized = VersionComparator.normalize_version(max_version)
|
||||
|
||||
|
||||
# 检查兼容性映射表
|
||||
if max_normalized in VersionComparator.COMPATIBILITY_MAP:
|
||||
compatible_versions = VersionComparator.COMPATIBILITY_MAP[max_normalized]
|
||||
if current_normalized in compatible_versions:
|
||||
return True, f"根据兼容性映射表,版本 {current_normalized} 与 {max_normalized} 兼容"
|
||||
|
||||
|
||||
return False, ""
|
||||
|
||||
@staticmethod
|
||||
@@ -156,13 +155,13 @@ class VersionComparator:
|
||||
if max_version:
|
||||
max_normalized = VersionComparator.normalize_version(max_version)
|
||||
comparison = VersionComparator.compare_versions(version_normalized, max_normalized)
|
||||
|
||||
|
||||
if comparison > 0:
|
||||
# 严格版本检查失败,尝试兼容性检查
|
||||
is_compatible, compat_msg = VersionComparator.check_forward_compatibility(
|
||||
version_normalized, max_normalized
|
||||
)
|
||||
|
||||
|
||||
if is_compatible:
|
||||
logger.info(f"版本兼容性检查:{compat_msg}")
|
||||
return True, compat_msg
|
||||
@@ -183,7 +182,7 @@ class VersionComparator:
|
||||
@staticmethod
|
||||
def add_compatibility_mapping(base_version: str, compatible_versions: list) -> None:
|
||||
"""动态添加兼容性映射
|
||||
|
||||
|
||||
Args:
|
||||
base_version: 基础版本(插件声明的最大支持版本)
|
||||
compatible_versions: 兼容的版本列表
|
||||
@@ -197,7 +196,7 @@ class VersionComparator:
|
||||
@staticmethod
|
||||
def get_compatibility_info() -> Dict[str, list]:
|
||||
"""获取当前的兼容性映射表
|
||||
|
||||
|
||||
Returns:
|
||||
Dict[str, list]: 兼容性映射表的副本
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user