From 14cfc2feebde33c5a94c53937110a6aa2c543865 Mon Sep 17 00:00:00 2001 From: Bjarke Sporring Date: Wed, 14 Jan 2026 16:56:29 +0100 Subject: [PATCH] Fix Git version check to handle Windows formatting - Update Test-GitVersion to properly parse Git versions with Windows suffixes - Handle formats like '2.52.0.windows.1' correctly - Parse major and minor version numbers separately for accurate comparison - Now correctly identifies versions 2.23+ regardless of Windows-specific suffixes - Add better error message when version parsing fails --- install-prerequisites.ps1 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/install-prerequisites.ps1 b/install-prerequisites.ps1 index 98028c3..770f5b4 100644 --- a/install-prerequisites.ps1 +++ b/install-prerequisites.ps1 @@ -185,17 +185,24 @@ function Test-GitVersion { } $version = Get-InstalledVersion 'git' - if ($version -match 'git version (\d+\.\d+)') { - $versionNumber = [decimal]$matches[1] - if ($versionNumber -ge 2.23) { + + # Parse Git version from various formats: + # "git version 2.52.0", "git version 2.52.0.windows.1", etc. + if ($version -match 'git version (\d+)\.(\d+)') { + $majorVersion = [int]$matches[1] + $minorVersion = [int]$matches[2] + + # Check if version is 2.23 or higher + if ($majorVersion -gt 2 -or ($majorVersion -eq 2 -and $minorVersion -ge 23)) { return $true } else { - Write-Warning "Git version $versionNumber is below required version 2.23" + Write-Warning "Git version $majorVersion.$minorVersion is below required version 2.23" return $false } } + Write-Warning "Could not parse Git version from: $version" return $false }