전체 설치 스크립트 GitHub 릴리스 에셋 검증 및 폴백 다운로드 방어 로직 적용

This commit is contained in:
mcchae committed 2026-10-31 04:54:34 +09:00
1 parent 5a67e7bbcf
commit b41d2f68f3
21 files changed
+541 -190

No files matched your search

+32 -16
View File
@@ -46,10 +46,11 @@ $ErrorActionPreference = 'Stop'
# ────────────────────────────────────────────
# Constants
# ────────────────────────────────────────────
$REPO = "jesseduffield/lazygit"
$API_URL = "https://api.github.com/repos/$REPO/releases"
$GIT_REPO = "git-for-windows/git"
$GIT_API_URL = "https://api.github.com/repos/$GIT_REPO/releases"
$REPO = "jesseduffield/lazygit"
$API_URL = "https://api.github.com/repos/$REPO/releases"
$FALLBACK_TAG = "v0.61.1"
$GIT_REPO = "git-for-windows/git"
$GIT_API_URL = "https://api.github.com/repos/$GIT_REPO/releases"
# ────────────────────────────────────────────
# Utility functions
@@ -254,18 +255,21 @@ function Get-LatestTag {
try {
$releases = Invoke-RestMethod -Uri $API_URL -UseBasicParsing `
-Headers @{ 'User-Agent' = 'install-lazygit-ps1' }
-Headers @{ 'User-Agent' = 'install-lazygit-ps1' } -TimeoutSec 15
$latest = $releases | Where-Object {
$_.prerelease -eq $false -and $_.assets -and $_.assets.Count -gt 0
} | Select-Object -First 1
if ($latest -and $latest.tag_name) {
return $latest.tag_name
}
} catch {
Write-Err "Failed to call GitHub API: $_"
Write-Warn "GitHub API lookup failed: $_"
}
$latest = $releases | Where-Object { $_.prerelease -eq $false } | Select-Object -First 1
if (-not $latest) {
Write-Err "Could not find latest release."
}
return $latest.tag_name
Write-Warn "Using fallback release tag: $FALLBACK_TAG"
return $FALLBACK_TAG
}
# ────────────────────────────────────────────
@@ -282,7 +286,7 @@ function Get-DownloadUrl {
# Download, extract & install
# ────────────────────────────────────────────
function Install-Lazygit {
param([string]$Url)
param([string]$Url, [string]$FallbackUrl)
$tmpDir = Join-Path $env:TEMP "lazygit_install_$(Get-Random)"
New-Item -ItemType Directory -Path $tmpDir | Out-Null
@@ -296,7 +300,18 @@ function Install-Lazygit {
Invoke-WebRequest -Uri $Url -OutFile $zipPath -UseBasicParsing
$ProgressPreference = 'Continue'
} catch {
Write-Err "Download failed: $_"
if ($FallbackUrl -and ($FallbackUrl -ne $Url)) {
Write-Warn "Primary download failed. Retrying with fallback URL: $FallbackUrl"
try {
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $FallbackUrl -OutFile $zipPath -UseBasicParsing
$ProgressPreference = 'Continue'
} catch {
Write-Err "Download failed: $_"
}
} else {
Write-Err "Download failed: $_"
}
}
Write-Info "Extracting..."
@@ -370,7 +385,8 @@ function Main {
Write-Info "Latest release: $tag"
$url = Get-DownloadUrl -Tag $tag -Platform $platform
Install-Lazygit -Url $url
$fallbackUrl = Get-DownloadUrl -Tag $FALLBACK_TAG -Platform $platform
Install-Lazygit -Url $url -FallbackUrl $fallbackUrl
if ($AddToPath) {
Add-ToUserPath -Dir $InstallDir