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

Function resolve_change_reference

libatomic/src/daemon/services.rs:1091–1116  ·  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

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