From 6f40ff9e2504157156ee25a31c13d42d1401276b Mon Sep 17 00:00:00 2001 From: DuProcess <273172371+DuProcess@users.noreply.github.com> Date: Sun, 21 Jun 2026 15:52:42 -0400 Subject: [PATCH] Prefer direct Gitea release assets --- install.ps1 | 35 ++++++++++++++++++++++++++++++++++- install.sh | 4 ++-- src/bin/dosh-client.rs | 14 ++++++-------- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/install.ps1 b/install.ps1 index f03dab3..8ad9853 100644 --- a/install.ps1 +++ b/install.ps1 @@ -70,6 +70,36 @@ function Release-DownloadUrl { "$web/releases/download/$BinaryVersion/$name" } +function Release-LatestTagDownloadUrl { + if ($BinaryUrl -or $BinaryBase -or $BinaryVersion -ne "latest") { + return $null + } + $web = Repo-WebBase $Repo + if (-not $web) { + return $null + } + try { + $response = Invoke-WebRequest -UseBasicParsing -Uri "$web/releases/latest" -MaximumRedirection 5 + $effective = $null + if ($response.BaseResponse.ResponseUri) { + $effective = $response.BaseResponse.ResponseUri.AbsoluteUri + } elseif ($response.BaseResponse.RequestMessage -and $response.BaseResponse.RequestMessage.RequestUri) { + $effective = $response.BaseResponse.RequestMessage.RequestUri.AbsoluteUri + } + $prefix = "$web/releases/tag/" + if ($effective -and $effective.StartsWith($prefix)) { + $tag = $effective.Substring($prefix.Length) + if ($tag) { + return "$web/releases/download/$tag/$(Release-ArtifactName)" + } + } + } + catch { + return $null + } + return $null +} + function Verify-ArchiveChecksum($Url, $Archive) { $checksumPath = "$Archive.sha256" try { @@ -91,7 +121,10 @@ $configDir = Join-Path $HOME ".config\dosh" New-Item -ItemType Directory -Force -Path $bindir, $configDir | Out-Null function Install-Prebuilt { - $url = Release-DownloadUrl + $url = Release-LatestTagDownloadUrl + if (-not $url) { + $url = Release-DownloadUrl + } if (-not $url) { return $false } diff --git a/install.sh b/install.sh index 403cf01..f243665 100755 --- a/install.sh +++ b/install.sh @@ -265,7 +265,7 @@ verify_archive_checksum() { } try_install_prebuilt() { - download_url="$(release_download_url)" || return 1 + download_url="$(release_latest_tag_download_url || release_download_url)" || return 1 tmpdir="$(mktemp -d)" archive="$tmpdir/$(release_artifact_name)" checksum_file="$archive.sha256" @@ -273,7 +273,7 @@ try_install_prebuilt() { need curl need tar if ! curl -fsL "$download_url" -o "$archive" 2>/dev/null; then - alt_download_url="$(release_latest_tag_download_url || true)" + alt_download_url="$(release_download_url || true)" if [ -z "$alt_download_url" ] || ! curl -fsL "$alt_download_url" -o "$archive"; then echo "prebuilt unavailable: $download_url" >&2 [ -z "$alt_download_url" ] || echo "prebuilt unavailable: $alt_download_url" >&2 diff --git a/src/bin/dosh-client.rs b/src/bin/dosh-client.rs index daacd58..cd422ce 100644 --- a/src/bin/dosh-client.rs +++ b/src/bin/dosh-client.rs @@ -1431,13 +1431,13 @@ fn run_update(config: &dosh::config::ClientConfig, check_only: bool) -> Result<( if let Some(latest_url) = latest_release_download_url(&repo, artifact) { let mut status = "missing"; let mut display_url = latest_url.clone(); - if url_reachable(&latest_url)? { - status = "available"; - } else if let Some(tag_url) = latest_release_tag_download_url(&repo, artifact)? + if let Some(tag_url) = latest_release_tag_download_url(&repo, artifact)? && url_reachable(&tag_url)? { status = "available"; display_url = tag_url; + } else if url_reachable(&latest_url)? { + status = "available"; } println!("prebuilt: {status} ({artifact})"); println!("prebuilt_url: {display_url}"); @@ -4848,17 +4848,15 @@ impl DisconnectStatus { Ok(()) } - /// Paint `text` on the terminal's bottom row using save/restore cursor so the - /// app's cursor is untouched. Sequence: save cursor (ESC 7), move to the last - /// row col 1, clear that row, set reverse-video cyan, write text, reset - /// attributes, restore cursor (ESC 8). + /// Paint `text` on the terminal's top row using save/restore cursor so the + /// app's cursor is untouched. fn emit(&self, text: &str) -> Result<()> { let (_, rows) = terminal_size(); let bytes = render_status_overlay(text, rows); emit_status(&bytes) } - /// Erase the bottom-row status line, again with save/restore cursor. + /// Erase the top-row status bar, again with save/restore cursor. fn emit_clear(&self) -> Result<()> { let (_, rows) = terminal_size(); emit_status(&render_status_clear(rows))