From f2511f188cf4353efee727986df537b2fb2b474e Mon Sep 17 00:00:00 2001 From: ytshen Date: Tue, 30 Dec 2025 17:28:06 +0800 Subject: [PATCH] feat: use lenient version matching for compatibility check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use target="7.*" instead of "7.0" to match any version in the major version series. This allows plugins with min=7.5.0 to still appear in the Zotero 7 compatible list. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/zotero_scraper/cache/release_cache.py | 2 +- src/zotero_scraper/utils/version.py | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/zotero_scraper/cache/release_cache.py b/src/zotero_scraper/cache/release_cache.py index 39ea054..bf331ed 100644 --- a/src/zotero_scraper/cache/release_cache.py +++ b/src/zotero_scraper/cache/release_cache.py @@ -76,7 +76,7 @@ class CachedRelease: # Target version X.0 must be within [min_version, max_version] # e.g., for target "7", check if 7.0 >= min_ver and 7.0 <= max_ver - target = f"{zotero_version}.0" + target = f"{zotero_version}.*" return ( compare_versions(target, min_ver) >= 0 diff --git a/src/zotero_scraper/utils/version.py b/src/zotero_scraper/utils/version.py index b083a5a..0752cd4 100644 --- a/src/zotero_scraper/utils/version.py +++ b/src/zotero_scraper/utils/version.py @@ -37,15 +37,27 @@ def compare_versions(version1: Union[str, int], version2: Union[str, int]) -> in if p1 == "*" or p2 == "*": continue - # Try numeric comparison - try: + # Check if parts are numeric + p1_is_num = p1.isdigit() + p2_is_num = p2.isdigit() + + if p1_is_num and p2_is_num: + # Both numeric - compare as integers n1, n2 = int(p1), int(p2) if n1 < n2: return -1 elif n1 > n2: return 1 - except ValueError: - # Fall back to string comparison for non-numeric parts + elif p1_is_num and not p2_is_num: + # p1 is numeric (stable), p2 is pre-release (alpha/beta/rc) + # Stable > pre-release, so p1 > p2 + return 1 + elif not p1_is_num and p2_is_num: + # p1 is pre-release, p2 is numeric (stable) + # Pre-release < stable, so p1 < p2 + return -1 + else: + # Both non-numeric - string comparison if p1 < p2: return -1 elif p1 > p2: