Skip to content

Commit 7ca98bf

Browse files
committed
fix(version-extraction): support date-based version numbers
Problem: - ruby-build shows blue ? instead of green ✅ despite versions matching - Snapshot shows latest_version: '' (empty string) - extract_version_number() regex requires dots, fails on date versions Root cause: - Regex pattern \d+(?:\.\d+)+ requires at least one dot - Date-based versions like '20251023' have no dots - Version extraction fails, returns empty string - Status becomes UNKNOWN instead of UP-TO-DATE Solution: - Change regex from \d+(?:\.\d+)+ to \d+(?:\.\d+)* - Makes dots optional (zero or more instead of one or more) - Now supports both formats: - Semantic: 1.2.3, 1.2.3.4 - Date-based: 20251023, 20250822 Impact: - ruby-build: 20251023 === 20251023 (green ✅) - parallel: 20250822 detected correctly - All dotted versions still work (1.2.3, etc) Verification: - Tested: 20251023, v20251023, 1.2.3, v1.2.3, ruby-build-20251023 - All extract correctly with new regex - Status determination now accurate for date-based tools
1 parent aeba636 commit 7ca98bf

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

cli_audit/collectors.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ def extract_version_number(s: str) -> str:
5555
"""Extract version number from a string.
5656
5757
Args:
58-
s: String potentially containing version (e.g., "v1.2.3", "tool-1.2.3")
58+
s: String potentially containing version (e.g., "v1.2.3", "tool-1.2.3", "20251023")
5959
6060
Returns:
61-
Version number (e.g., "1.2.3") or empty string if not found
61+
Version number (e.g., "1.2.3", "20251023") or empty string if not found
6262
"""
6363
s = normalize_version_tag(s)
64-
# Match version patterns like 1.2.3, 1.2, 1.2.3.4
65-
match = re.search(r"\d+(?:\.\d+)+", s)
64+
# Match version patterns: 1.2.3, 1.2, 1.2.3.4, 20251023 (date-based)
65+
match = re.search(r"\d+(?:\.\d+)*", s)
6666
return match.group(0) if match else ""
6767

6868

tools_snapshot.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"__meta__": {
3-
"collected_at": "2025-11-06T11:04:19Z",
3+
"collected_at": "2025-11-06T12:07:35Z",
44
"count": 1,
5-
"created_at": "2025-11-06T11:04:19Z",
5+
"created_at": "2025-11-06T12:07:35Z",
66
"offline": false,
77
"partial_failures": 0,
88
"schema_version": 1
@@ -11,16 +11,16 @@
1111
{
1212
"category": "other",
1313
"hint": "",
14-
"installed": "1.8.17",
15-
"installed_method": "uv",
16-
"installed_version": "1.8.17",
17-
"latest_upstream": "1.8.17",
18-
"latest_url": "https://pypi.org/project/codex/",
19-
"latest_version": "1.8.17",
14+
"installed": "20251023",
15+
"installed_method": "version_command",
16+
"installed_version": "20251023",
17+
"latest_upstream": "20251023",
18+
"latest_url": "https://github.com/rbenv/ruby-build/releases/tag/20251023",
19+
"latest_version": "20251023",
2020
"status": "UP-TO-DATE",
21-
"tool": "codex",
22-
"tool_url": "https://pypi.org/project/codex/",
23-
"upstream_method": "pypi"
21+
"tool": "ruby-build",
22+
"tool_url": "https://github.com/rbenv/ruby-build",
23+
"upstream_method": "gh"
2424
}
2525
]
2626
}

0 commit comments

Comments
 (0)