diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-04-16 01:09:25 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-04-16 01:09:25 +0300 |
| commit | ef1c6b1497fd0ad26e9d32f301ffb801cb96aa40 (patch) | |
| tree | f80cbb5fc67eb2796c932a9fdd5315ce3d21d18e /src/update.rs | |
| parent | d76a5b8cec72b420b340a13ea186ea169b39b69e (diff) | |
fix: switch updates to manual preview flow
Diffstat (limited to 'src/update.rs')
| -rw-r--r-- | src/update.rs | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/src/update.rs b/src/update.rs index 4be993dc..af446fed 100644 --- a/src/update.rs +++ b/src/update.rs @@ -1,6 +1,8 @@ //! Self-update mechanism. //! -//! Checks the hosted herdr.dev update manifest for newer versions and downloads the binary. +//! Checks the hosted herdr.dev update manifest for newer versions. +//! Manual `herdr update` downloads and installs the binary. +//! Background checks only surface availability and release notes. //! Uses `curl` as a subprocess for HTTP — no additional Rust HTTP dependencies. //! JSON parsing uses serde_json (already in deps for persistence). @@ -14,8 +16,20 @@ use serde::Deserialize; const UPDATE_MANIFEST_URL: &str = "https://herdr.dev/latest.json"; const CURRENT_VERSION: &str = env!("CARGO_PKG_VERSION"); const FAKE_UPDATE_VERSION_ENV: &str = "HERDR_FAKE_UPDATE_VERSION"; +const FAKE_UPDATE_NOTES_VERSION_ENV: &str = "HERDR_FAKE_UPDATE_NOTES_VERSION"; +const DEFAULT_FAKE_UPDATE_NOTES_VERSION: &str = "0.3.0"; fn fake_release_notes_body(version: &str) -> String { + let notes_version = env::var(FAKE_UPDATE_NOTES_VERSION_ENV) + .ok() + .map(|value| value.trim().to_string()) + .filter(|value| !value.is_empty()) + .unwrap_or_else(|| DEFAULT_FAKE_UPDATE_NOTES_VERSION.to_string()); + + if let Some(notes) = crate::release_notes::load_preview_from_local_changelog(¬es_version) { + return notes.body; + } + format!( "### Changed\n- Test update v{version} for local UI validation.\n\n### Notes\n- This is stub release-notes content generated by {FAKE_UPDATE_VERSION_ENV}." ) @@ -228,7 +242,7 @@ pub fn self_update() -> Result<Version, String> { Ok(release.version) } -/// Background auto-update: check, download, install, notify TUI. +/// Background update check: only surface availability and release notes. /// Runs in a background thread at startup. pub fn auto_update(events: tokio::sync::mpsc::Sender<crate::events::AppEvent>) { if let Ok(version) = env::var(FAKE_UPDATE_VERSION_ENV) { @@ -257,7 +271,7 @@ pub fn auto_update(events: tokio::sync::mpsc::Sender<crate::events::AppEvent>) { }; tracing::info!( - "new version v{} available, downloading from {}", + "new version v{} available at {}", release.version, release.download_url ); @@ -268,13 +282,8 @@ pub fn auto_update(events: tokio::sync::mpsc::Sender<crate::events::AppEvent>) { tracing::warn!("failed to save pending release notes: {e}"); } - if let Err(e) = download_and_install(&release) { - tracing::warn!("auto-update failed: {e}"); - return; - } - tracing::info!( - "auto-update: v{} installed, restart to use", + "auto-update check: v{} available, waiting for manual install", release.version ); @@ -348,11 +357,24 @@ mod tests { } #[test] - fn fake_release_notes_include_version_and_context() { + fn fake_release_notes_default_to_real_large_changelog_section() { + std::env::remove_var(FAKE_UPDATE_NOTES_VERSION_ENV); + + let body = fake_release_notes_body("9.4.9"); + assert!(body.contains("### Major Changes")); + assert!(body.contains("Added tabs within workspaces")); + } + + #[test] + fn fake_release_notes_fallback_include_version_and_context() { + std::env::set_var(FAKE_UPDATE_NOTES_VERSION_ENV, "does-not-exist"); + let body = fake_release_notes_body("9.4.9"); assert!(body.contains("v9.4.9")); assert!(body.contains("local UI validation")); assert!(body.contains(FAKE_UPDATE_VERSION_ENV)); + + std::env::remove_var(FAKE_UPDATE_NOTES_VERSION_ENV); } #[test] |
