mirror of
https://github.com/cmderdev/cmder.git
synced 2025-11-08 21:29:02 +08:00
Fix pre-release filtering for archive downloads
Co-authored-by: DRSDavidSoft <4673812+DRSDavidSoft@users.noreply.github.com>
This commit is contained in:
@@ -196,15 +196,42 @@ function Fetch-DownloadUrl {
|
||||
|
||||
# Special case for archive downloads of repository
|
||||
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")) {
|
||||
# Find the first release that matches our pre-release filtering criteria
|
||||
$selectedRelease = $null
|
||||
foreach ($release in $info) {
|
||||
# Apply the same filtering logic
|
||||
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] = $info[0].tag_name + ".zip"
|
||||
$p[$i + 1] = $selectedRelease.tag_name + ".zip"
|
||||
$downloadLinks = $url.Scheme + "://" + $url.Host + ($p -join '')
|
||||
return $downloadLinks
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user