Skip to content

Commit 8e55514

Browse files
committed
skip updates if not updating to the actual latest version
1 parent 24913b1 commit 8e55514

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

updater/scripts/update-dependency.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,30 @@ if ("$Tag" -eq "")
167167
{
168168
return
169169
}
170+
171+
# It's possible that the dependency was updated to a pre-release version manually in which case we don't want to
172+
# 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': $_"
182+
}
183+
184+
# Verify that the latest tag actually points to a different commit. Otherwise, we don't need to update.
185+
$refs = $(git ls-remote --tags $url)
186+
$refOriginal = (($refs -match "refs/tags/$originalTag" ) -split "[ \t]") | Select-Object -First 1
187+
$refLatest = (($refs -match "refs/tags/$latestTag" ) -split "[ \t]") | Select-Object -First 1
188+
if ($refOriginal -eq $refLatest)
189+
{
190+
Write-Host "Latest tag '$latestTag' points to the same commit as the original tag '$originalTag'. Skipping update."
191+
return
192+
}
193+
170194
$Tag = $latestTag
171195
}
172196

0 commit comments

Comments
 (0)