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

Function resolve_change_reference

libatomic/src/daemon/services.rs:1090–1115  ·  view source on GitHub ↗

Resolve one raw change reference with the local insert bodies' semantics: a full base32 hash parses directly; otherwise a case-insensitive unique prefix over the change store, refusing with the local messages on no match / ambiguity.

(
    repo: &Repository,
    reference: &str,
)

Source from the content-addressed store, hash-verified

1088/// case-insensitive unique prefix over the change store, refusing with
1089/// the local messages on no match / ambiguity.
1090fn resolve_change_reference(
1091 repo: &Repository,
1092 reference: &str,
1093) -> Result<atomic_core::types::Merkle, Status> {
1094 use atomic_core::types::Base32;
1095 if let Some(hash) = atomic_core::types::Merkle::from_base32(reference.as_bytes()) {
1096 return Ok(hash);
1097 }
1098 if reference.len() >= 2 {
1099 match repo.find_change_by_prefix(reference) {
1100 Ok(Some(hash)) => return Ok(hash),
1101 Ok(None) => {}
1102 Err(atomic_repository::RepositoryError::AmbiguousHash { .. }) => {
1103 return Err(domain_status(
1104 ErrorCode::NotFound,
1105 format!("Ambiguous change hash '{reference}' - matches multiple changes"),
1106 ));
1107 }
1108 Err(error) => return Err(repository_error(error)),
1109 }
1110 }
1111 Err(domain_status(
1112 ErrorCode::NotFound,
1113 format!("Change not found: {reference}"),
1114 ))
1115}
1116
1117/// The single-insert domain calls the local single-insert body makes:
1118/// the dependency closure by default, `--deps=false` skips it (the

Callers 1

insert_changesMethod · 0.85

Calls 5

domain_statusFunction · 0.85
find_change_by_prefixMethod · 0.80
repository_errorFunction · 0.70
as_bytesMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected