Skip to content

Commit 9b56391

Browse files
committed
fixes
1 parent 8e55514 commit 9b56391

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

updater/scripts/common.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
function GetComparableVersion([Parameter(Mandatory = $true)][string] $value)
3+
{
4+
$value = $value -replace '^v', ''
5+
try {
6+
[System.Management.Automation.SemanticVersion]::Parse($value)
7+
} catch {
8+
Write-Warning "Failed to parse string '$value' as semantic version: $_"
9+
$null
10+
}
11+
}

updater/scripts/sort-versions.ps1

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,7 @@ param(
33
)
44

55
Set-StrictMode -Version latest
6-
7-
function GetComparableVersion([Parameter(Mandatory = $true)][string] $value)
8-
{
9-
$value = $value -replace '^v', ''
10-
try {
11-
[System.Management.Automation.SemanticVersion]::Parse($value)
12-
} catch {
13-
Write-Warning "Failed to parse semantic version '$value': $_"
14-
$null
15-
}
16-
}
6+
. "$PSScriptRoot/common.ps1"
177

188
$List `
199
| Where-Object { $null -ne (GetComparableVersion $_) } `

updater/scripts/update-dependency.ps1

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ param(
1414
)
1515

1616
Set-StrictMode -Version latest
17+
. "$PSScriptRoot/common.ps1"
1718

1819
if (-not (Test-Path $Path ))
1920
{
@@ -170,15 +171,10 @@ if ("$Tag" -eq "")
170171

171172
# It's possible that the dependency was updated to a pre-release version manually in which case we don't want to
172173
# roll back, even though it's not the latest version matching the configured pattern.
173-
try {
174-
if ([System.Management.Automation.SemanticVersion]::Parse(($originalTag -replace '^v', '')) `
175-
-ge [System.Management.Automation.SemanticVersion]::Parse(($latestTag -replace '^v', '')))
176-
{
177-
Write-Host "SemVer represented by the original tag '$originalTag' is newer than the latest tag '$latestTag'. Skipping update."
178-
return
179-
}
180-
} catch {
181-
Write-Warning "Failed to parse semantic version '$value': $_"
174+
if ((GetComparableVersion $originalTag) -ge (GetComparableVersion $latestTag))
175+
{
176+
Write-Host "SemVer represented by the original tag '$originalTag' is newer than the latest tag '$latestTag'. Skipping update."
177+
return
182178
}
183179

184180
# Verify that the latest tag actually points to a different commit. Otherwise, we don't need to update.

0 commit comments

Comments
 (0)