From c28151cc1915169f3a7419aa2086c239607c1b09 Mon Sep 17 00:00:00 2001 From: Bjarke Sporring Date: Wed, 14 Jan 2026 17:24:33 +0100 Subject: [PATCH] Fix version parsing in Install-Package for Windows Git format - Update regex to extract only semantic version numbers (x.y.z) - Prevents matching entire string like '2.52.0.windows.1' - Uses '^(\d+(?:\.\d+){1,2})' to match version at start of string only - Extracts '2.52.0' from '2.52.0.windows.1' for proper version comparison - Handles Windows Git version suffixes correctly - Maintains compatibility with standard version formats --- install.ps1 | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/install.ps1 b/install.ps1 index f329d69..fc9254e 100644 --- a/install.ps1 +++ b/install.ps1 @@ -129,17 +129,29 @@ function Install-Package { Write-Success "$Name is already installed: $version" if ($MinVersion -and $version) { - # Basic version check (not perfect but good enough for common cases) - if ($version -match '(\d+\.[\d.]+)') { + # Extract semantic version numbers only - stop before any non-digit/non-dot characters + # This extracts "2.52.0" from "2.52.0.windows.1" + if ($version -match '^(\d+(?:\.\d+){1,2})') { $installedVersion = $matches[1] - if ([version]$installedVersion -lt [version]$MinVersion) { - Write-Warning "Version $installedVersion is below minimum required version $MinVersion" - Write-Host " Attempting to upgrade..." -ForegroundColor Cyan + try { + if ([version]$installedVersion -lt [version]$MinVersion) { + Write-Warning "Version $installedVersion is below minimum required version $MinVersion" + Write-Host " Attempting to upgrade..." -ForegroundColor Cyan + } + else { + return $true + } } - else { + catch { + Write-Warning "Version comparison failed - assuming sufficient version" return $true } } + else { + Write-Warning "Could not parse version from: $version" + Write-Host " Assuming installed version is sufficient..." -ForegroundColor Cyan + return $true + } } else { return $true