Fix pre-release filtering for archive downloads

Co-authored-by: DRSDavidSoft <4673812+DRSDavidSoft@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-07 14:36:57 +00:00
parent a513d08ab8
commit d01ab39181

View File

@@ -196,12 +196,39 @@ function Fetch-DownloadUrl {
# Special case for archive downloads of repository # Special case for archive downloads of repository
if (($null -eq $downloadLinks) -or (-not $downloadLinks)) { if (($null -eq $downloadLinks) -or (-not $downloadLinks)) {
if ((($p | ForEach-Object { $_.Trim('/') }) -contains "archive") -and $info[0].tag_name) { if ((($p | ForEach-Object { $_.Trim('/') }) -contains "archive")) {
for ($i = 0; $i -lt $p.Length; $i++) { # Find the first release that matches our pre-release filtering criteria
if ($p[$i].Trim('/') -eq "archive") { $selectedRelease = $null
$p[$i + 1] = $info[0].tag_name + ".zip" foreach ($release in $info) {
$downloadLinks = $url.Scheme + "://" + $url.Host + ($p -join '') # Apply the same filtering logic
return $downloadLinks if (-not $includePrerelease) {
if ($release.prerelease -eq $true) {
continue
}
$prereleaseKeywords = @('-rc', '-beta', '-alpha', '-preview', '-pre')
$isPrerelease = $false
foreach ($keyword in $prereleaseKeywords) {
if ($release.tag_name -ilike "*$keyword*") {
$isPrerelease = $true
break
}
}
if ($isPrerelease) {
continue
}
}
# Use the first release that passes the filter
$selectedRelease = $release
break
}
if ($selectedRelease -and $selectedRelease.tag_name) {
for ($i = 0; $i -lt $p.Length; $i++) {
if ($p[$i].Trim('/') -eq "archive") {
$p[$i + 1] = $selectedRelease.tag_name + ".zip"
$downloadLinks = $url.Scheme + "://" + $url.Host + ($p -join '')
return $downloadLinks
}
} }
} }
} }