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
This commit is contained in:
24
install.ps1
24
install.ps1
@@ -129,17 +129,29 @@ function Install-Package {
|
|||||||
Write-Success "$Name is already installed: $version"
|
Write-Success "$Name is already installed: $version"
|
||||||
|
|
||||||
if ($MinVersion -and $version) {
|
if ($MinVersion -and $version) {
|
||||||
# Basic version check (not perfect but good enough for common cases)
|
# Extract semantic version numbers only - stop before any non-digit/non-dot characters
|
||||||
if ($version -match '(\d+\.[\d.]+)') {
|
# This extracts "2.52.0" from "2.52.0.windows.1"
|
||||||
|
if ($version -match '^(\d+(?:\.\d+){1,2})') {
|
||||||
$installedVersion = $matches[1]
|
$installedVersion = $matches[1]
|
||||||
if ([version]$installedVersion -lt [version]$MinVersion) {
|
try {
|
||||||
Write-Warning "Version $installedVersion is below minimum required version $MinVersion"
|
if ([version]$installedVersion -lt [version]$MinVersion) {
|
||||||
Write-Host " Attempting to upgrade..." -ForegroundColor Cyan
|
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
|
return $true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Write-Warning "Could not parse version from: $version"
|
||||||
|
Write-Host " Assuming installed version is sufficient..." -ForegroundColor Cyan
|
||||||
|
return $true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return $true
|
return $true
|
||||||
|
|||||||
Reference in New Issue
Block a user