MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / execute

Method execute

atomic-cli/src/commands/update.rs:536–577  ·  view source on GitHub ↗

Pure business logic. Returns an `UpdateOutcome`, or a `CliError::RemoteError` for network / GitHub failures. Caller decides exit code and presentation.

(&self)

Source from the content-addressed store, hash-verified

534 /// `CliError::RemoteError` for network / GitHub failures. Caller
535 /// decides exit code and presentation.
536 async fn execute(&self) -> CliResult<UpdateOutcome> {
537 let env = StdEnv;
538 let source = match std::env::current_exe() {
539 Ok(p) => detect_source(&p, &env),
540 Err(_) => InstallSource::Unknown,
541 };
542
543 let current = env!("CARGO_PKG_VERSION").to_string();
544 let latest_tag = fetch_latest(&env).await?;
545 let latest = latest_tag
546 .strip_prefix('v')
547 .unwrap_or(&latest_tag)
548 .to_string();
549
550 Ok(match (parse_version(&current), parse_version(&latest)) {
551 (Some(c), Some(l)) if c == l => UpdateOutcome::UpToDate { current, source },
552 (Some(c), Some(l)) if c > l => UpdateOutcome::AheadOfRelease {
553 current,
554 latest,
555 source,
556 },
557 (Some(_), Some(_)) => {
558 let drift = match &source {
559 InstallSource::OfficialInstaller {
560 recorded_version, ..
561 } if recorded_version != &current => Some(recorded_version.clone()),
562 _ => None,
563 };
564 UpdateOutcome::Outdated {
565 current,
566 latest,
567 source,
568 drift_manifest_version: drift,
569 }
570 }
571 _ => UpdateOutcome::UnknownVersion {
572 current,
573 latest,
574 source,
575 },
576 })
577 }
578}
579
580// Tests — inline because atomic-cli is a binary crate with no lib.rs,

Callers 1

runMethod · 0.45

Calls 4

detect_sourceFunction · 0.85
fetch_latestFunction · 0.85
parse_versionFunction · 0.70
cloneMethod · 0.45

Tested by

no test coverage detected