From f2e8ae51894fa197cd39b45bc0b4fd4c4e606bc6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 8 Dec 2025 20:56:30 +0000 Subject: [PATCH] Improve version parsing to handle complex version strings Co-authored-by: DRSDavidSoft <4673812+DRSDavidSoft@users.noreply.github.com> --- .github/workflows/vendor.yml | 36 +++++++++++++++++++++++---------- scripts/update.ps1 | 39 ++++++++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 22 deletions(-) diff --git a/.github/workflows/vendor.yml b/.github/workflows/vendor.yml index 0f54f6f..d1276bf 100644 --- a/.github/workflows/vendor.yml +++ b/.github/workflows/vendor.yml @@ -56,18 +56,32 @@ jobs: $changeType = "unknown" $emoji = "🔄" try { - $oldVer = [System.Version]::Parse($oldVersion.Split('-')[0]) - $newVer = [System.Version]::Parse($s.version.Split('-')[0]) + # Handle versions with more than 4 parts + $oldVerStr = $oldVersion.Split('-')[0] + $newVerStr = $s.version.Split('-')[0] - if ($newVer.Major -gt $oldVer.Major) { - $changeType = "major" - $emoji = "⚠️" - } elseif ($newVer.Minor -gt $oldVer.Minor) { - $changeType = "minor" - $emoji = "✨" - } else { - $changeType = "patch" - $emoji = "🐛" + # Split by dots and take only numeric parts, first 4 max + $oldParts = $oldVerStr.Split('.') | Where-Object { $_ -match '^\d+$' } | Select-Object -First 4 + $newParts = $newVerStr.Split('.') | Where-Object { $_ -match '^\d+$' } | Select-Object -First 4 + + # Ensure we have at least 2 parts (major.minor) + if ($oldParts.Count -ge 2 -and $newParts.Count -ge 2) { + $oldVerParseable = $oldParts -join '.' + $newVerParseable = $newParts -join '.' + + $oldVer = [System.Version]::Parse($oldVerParseable) + $newVer = [System.Version]::Parse($newVerParseable) + + if ($newVer.Major -gt $oldVer.Major) { + $changeType = "major" + $emoji = "⚠️" + } elseif ($newVer.Minor -gt $oldVer.Minor) { + $changeType = "minor" + $emoji = "✨" + } else { + $changeType = "patch" + $emoji = "🐛" + } } } catch { $changeType = "unknown" diff --git a/scripts/update.ps1 b/scripts/update.ps1 index fa108a9..2d1b5d1 100644 --- a/scripts/update.ps1 +++ b/scripts/update.ps1 @@ -303,21 +303,38 @@ foreach ($s in $sources) { # } $count++ - + # Analyze version change type $changeType = "unknown" try { # Try parsing as semantic version - $oldVer = [System.Version]::Parse($s.version.Split('-')[0]) - $newVer = [System.Version]::Parse($version.Split('-')[0]) - - if ($newVer.Major -gt $oldVer.Major) { - $changeType = "major" - $hasBreakingChanges = $true - } elseif ($newVer.Minor -gt $oldVer.Minor) { - $changeType = "minor" + # Handle versions with more than 4 parts by taking only the first 3-4 parts + $oldVerStr = $s.version.Split('-')[0] + $newVerStr = $version.Split('-')[0] + + # Split by dots and take only numeric parts, first 4 max + $oldParts = $oldVerStr.Split('.') | Where-Object { $_ -match '^\d+$' } | Select-Object -First 4 + $newParts = $newVerStr.Split('.') | Where-Object { $_ -match '^\d+$' } | Select-Object -First 4 + + # Ensure we have at least 2 parts (major.minor) + if ($oldParts.Count -ge 2 -and $newParts.Count -ge 2) { + $oldVerParseable = $oldParts -join '.' + $newVerParseable = $newParts -join '.' + + $oldVer = [System.Version]::Parse($oldVerParseable) + $newVer = [System.Version]::Parse($newVerParseable) + + if ($newVer.Major -gt $oldVer.Major) { + $changeType = "major" + $hasBreakingChanges = $true + } elseif ($newVer.Minor -gt $oldVer.Minor) { + $changeType = "minor" + } else { + $changeType = "patch" + } } else { - $changeType = "patch" + # Not enough numeric parts for semantic versioning + throw "Not enough numeric version parts" } } catch { # If semantic versioning fails, treat as unknown (potentially breaking) @@ -325,7 +342,7 @@ foreach ($s in $sources) { $hasBreakingChanges = $true Write-Verbose "Could not parse version as semantic version, treating as potentially breaking" } - + $updateDetails += @{ name = $s.name oldVersion = $s.version