Implement reversible Sentinel beta foundation
This commit is contained in:
@@ -96,14 +96,23 @@ function Compare-Version {
|
||||
[Parameter(Mandatory)][string]$Right
|
||||
)
|
||||
|
||||
try {
|
||||
$leftVersion = [System.Version]$Left
|
||||
$rightVersion = [System.Version]$Right
|
||||
return $leftVersion.CompareTo($rightVersion)
|
||||
}
|
||||
catch {
|
||||
return [string]::Compare($Left, $Right, $true)
|
||||
$pattern = '^(?<version>\d+(?:\.\d+){0,3})(?:-(?<prerelease>.+))?$'
|
||||
$leftMatch = [regex]::Match($Left, $pattern)
|
||||
$rightMatch = [regex]::Match($Right, $pattern)
|
||||
if ($leftMatch.Success -and $rightMatch.Success) {
|
||||
$numericComparison = ([System.Version]$leftMatch.Groups['version'].Value).CompareTo([System.Version]$rightMatch.Groups['version'].Value)
|
||||
if ($numericComparison -ne 0) {
|
||||
return $numericComparison
|
||||
}
|
||||
|
||||
$leftPrerelease = $leftMatch.Groups['prerelease'].Value
|
||||
$rightPrerelease = $rightMatch.Groups['prerelease'].Value
|
||||
if ([string]::IsNullOrWhiteSpace($leftPrerelease) -and -not [string]::IsNullOrWhiteSpace($rightPrerelease)) { return 1 }
|
||||
if (-not [string]::IsNullOrWhiteSpace($leftPrerelease) -and [string]::IsNullOrWhiteSpace($rightPrerelease)) { return -1 }
|
||||
return [string]::Compare($leftPrerelease, $rightPrerelease, $true)
|
||||
}
|
||||
|
||||
return [string]::Compare($Left, $Right, $true)
|
||||
}
|
||||
|
||||
function Get-Sha256Hex {
|
||||
|
||||
Reference in New Issue
Block a user