Skip to content

Commit

Permalink
feat: add rename infrastructure
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mistydemeo committed Dec 18, 2024
1 parent c46653d commit 7aa7cb6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
5 changes: 2 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ axoproject = { version = "=0.26.1", path = "axoproject", default-features = fals

# first-party deps
axocli = { version = "0.2.0" }
axoupdater = { version = "0.8.2" }
axoupdater = { git = "https://github.com/axodotdev/axoupdater", rev = "18bcd3e8937f05c24dec786860641f77e7931523" }
axotag = "0.2.0"
axoasset = { version = "1.2.0", features = ["json-serde", "toml-serde", "toml-edit", "yaml-serde", "compression", "remote"] }
axoprocess = { version = "0.2.0" }
Expand Down
21 changes: 14 additions & 7 deletions cargo-dist/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()? {
Expand Down
1 change: 1 addition & 0 deletions cargo-dist/tests/cli-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7aa7cb6

Please sign in to comment.