MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / run_upgrade

Function run_upgrade

src/upgrade.rs:853–884  ·  view source on GitHub ↗

Check for a newer version and perform the upgrade if one is available. Returns whether a new binary was actually installed.

()

Source from the content-addressed store, hash-verified

851///
852/// Returns whether a new binary was actually installed.
853pub fn run_upgrade() -> Result<UpgradeOutcome> {
854 let current = env!("CARGO_PKG_VERSION");
855 let is_beta = cloud::is_beta();
856 let channel = if is_beta { "beta" } else { "stable" };
857 let method = cloud::detect_install_method();
858
859 let method_suffix = match &method {
860 InstallMethod::Brew => " · Homebrew",
861 InstallMethod::Scoop => " · Scoop",
862 InstallMethod::Cargo => " · cargo",
863 InstallMethod::Unknown => "",
864 };
865 eprintln!("Current version: v{current} ({channel} channel{method_suffix})");
866
867 if matches!(method, InstallMethod::Brew) {
868 return run_brew_upgrade();
869 }
870
871 match upgrade_source_for(&method) {
872 UpgradeSource::CratesIo => {
873 run_versioned_upgrade(current, is_beta, &method, UpgradeSource::CratesIo).or_else(|error| {
874 eprintln!(
875 " \x1b[33mwarning:\x1b[0m crates.io update failed: {error}; falling back to GitHub releases"
876 );
877 run_versioned_upgrade(current, is_beta, &method, UpgradeSource::GitHubRelease)
878 })
879 }
880 UpgradeSource::GitHubRelease => {
881 run_versioned_upgrade(current, is_beta, &method, UpgradeSource::GitHubRelease)
882 }
883 }
884}
885
886/// Print the current channel.
887pub fn show_channel() {

Callers

nothing calls this directly

Calls 5

is_betaFunction · 0.85
detect_install_methodFunction · 0.85
run_brew_upgradeFunction · 0.85
upgrade_source_forFunction · 0.85
run_versioned_upgradeFunction · 0.85

Tested by

no test coverage detected