mirror of
https://github.com/cmderdev/cmder.git
synced 2025-12-15 10:18:53 +08:00
Improve version parsing to handle complex version strings
Co-authored-by: DRSDavidSoft <4673812+DRSDavidSoft@users.noreply.github.com>
This commit is contained in:
18
.github/workflows/vendor.yml
vendored
18
.github/workflows/vendor.yml
vendored
@@ -56,8 +56,21 @@ jobs:
|
|||||||
$changeType = "unknown"
|
$changeType = "unknown"
|
||||||
$emoji = "🔄"
|
$emoji = "🔄"
|
||||||
try {
|
try {
|
||||||
$oldVer = [System.Version]::Parse($oldVersion.Split('-')[0])
|
# Handle versions with more than 4 parts
|
||||||
$newVer = [System.Version]::Parse($s.version.Split('-')[0])
|
$oldVerStr = $oldVersion.Split('-')[0]
|
||||||
|
$newVerStr = $s.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) {
|
if ($newVer.Major -gt $oldVer.Major) {
|
||||||
$changeType = "major"
|
$changeType = "major"
|
||||||
@@ -69,6 +82,7 @@ jobs:
|
|||||||
$changeType = "patch"
|
$changeType = "patch"
|
||||||
$emoji = "🐛"
|
$emoji = "🐛"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
$changeType = "unknown"
|
$changeType = "unknown"
|
||||||
$emoji = "🔄"
|
$emoji = "🔄"
|
||||||
|
|||||||
@@ -308,8 +308,21 @@ foreach ($s in $sources) {
|
|||||||
$changeType = "unknown"
|
$changeType = "unknown"
|
||||||
try {
|
try {
|
||||||
# Try parsing as semantic version
|
# Try parsing as semantic version
|
||||||
$oldVer = [System.Version]::Parse($s.version.Split('-')[0])
|
# Handle versions with more than 4 parts by taking only the first 3-4 parts
|
||||||
$newVer = [System.Version]::Parse($version.Split('-')[0])
|
$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) {
|
if ($newVer.Major -gt $oldVer.Major) {
|
||||||
$changeType = "major"
|
$changeType = "major"
|
||||||
@@ -319,6 +332,10 @@ foreach ($s in $sources) {
|
|||||||
} else {
|
} else {
|
||||||
$changeType = "patch"
|
$changeType = "patch"
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
# Not enough numeric parts for semantic versioning
|
||||||
|
throw "Not enough numeric version parts"
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
# If semantic versioning fails, treat as unknown (potentially breaking)
|
# If semantic versioning fails, treat as unknown (potentially breaking)
|
||||||
$changeType = "unknown"
|
$changeType = "unknown"
|
||||||
|
|||||||
Reference in New Issue
Block a user