From c613fc81d959064c46bd884a0c548ee1ee0329ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Misty=20De=20M=C3=A9o?= Date: Tue, 17 Dec 2024 11:37:52 -0800 Subject: [PATCH] feat: add rename infrastructure This prepares us for a future rename: * It tries to load a receipt named "dist", in case this is a post-upgrade release; * If we load a "cargo-dist" receipt, it sets the internal name to "dist" to ensure that we look for the next release under the correct name. This shouldn't be merged until we know this is going to be the last pre-rename release. --- cargo-dist/src/main.rs | 21 ++++++++++++++------- cargo-dist/tests/cli-tests.rs | 1 + 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/cargo-dist/src/main.rs b/cargo-dist/src/main.rs index 140ef1484..c7c088b9f 100644 --- a/cargo-dist/src/main.rs +++ b/cargo-dist/src/main.rs @@ -729,7 +729,7 @@ async fn cmd_update(_config: &Cli, args: &cli::UpdateArgs) -> Result<(), miette: return Ok(()); } - let mut updater = AxoUpdater::new_for("cargo-dist"); + let mut updater = AxoUpdater::new_for("dist"); // If there's a specific version needed, random-access query it by tag, // because we always use the same tag format and this is fastest while @@ -759,12 +759,19 @@ async fn cmd_update(_config: &Cli, args: &cli::UpdateArgs) -> Result<(), miette: updater.set_github_token(&token); } - // Do we want to treat this as an error? - // Or do we want to sniff if this was a Homebrew installation? - if updater.load_receipt().is_err() { - eprintln!("Unable to load install receipt to check for updates."); - eprintln!("If you installed this via `brew`, please `brew upgrade cargo-dist`!"); - return Ok(()); + // First, try to check for a "dist" receipt + // (this might be a post-rename release) + if updater.load_receipt_as("dist").is_err() { + // If that didn't work, try again as "cargo-dist" + if updater + .load_receipt_as("cargo-dist") + .map(|updater| updater.set_name("dist")) + .is_err() + { + eprintln!("Unable to load install receipt to check for updates."); + eprintln!("If you installed this via `brew`, please `brew upgrade cargo-dist`!"); + return Ok(()); + } } if !updater.check_receipt_is_for_this_executable()? { diff --git a/cargo-dist/tests/cli-tests.rs b/cargo-dist/tests/cli-tests.rs index 753c3b666..a2c7a3f19 100644 --- a/cargo-dist/tests/cli-tests.rs +++ b/cargo-dist/tests/cli-tests.rs @@ -267,6 +267,7 @@ fn generate_installer(version: &axotag::Version, release_type: ReleaseSourceType } #[test] +#[ignore = "can't be reenabled until after the rename"] fn test_self_update() { // Only do this if RUIN_MY_COMPUTER_WITH_INSTALLERS is set if std::env::var(ENV_RUIN_ME)