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

Method resolve_hash_prefix

atomic-cli/src/commands/change/command.rs:227–250  ·  view source on GitHub ↗

Resolve a hash prefix to a full hash.

(
        &self,
        repo: &Repository,
        view_name: &str,
        prefix: &str,
    )

Source from the content-addressed store, hash-verified

225
226 /// Resolve a hash prefix to a full hash.
227 fn resolve_hash_prefix(
228 &self,
229 repo: &Repository,
230 view_name: &str,
231 prefix: &str,
232 ) -> CliResult<(Hash, Option<u64>)> {
233 // The repository's shared, case-insensitive prefix resolver (the
234 // same one `atomic insert` and `atomic unrecord` use).
235 match repo.find_change_by_prefix(prefix) {
236 Ok(Some(hash)) => {
237 let seq = self.find_sequence_for_hash(repo, view_name, &hash)?;
238 Ok((hash, seq))
239 }
240 Ok(None) => Err(CliError::ChangeNotFound {
241 hash: prefix.to_string(),
242 }),
243 Err(atomic_repository::RepositoryError::AmbiguousHash { prefix, matches }) => {
244 Err(CliError::AmbiguousHash {
245 hash: format!("{prefix} (matches: {})", matches.join(", ")),
246 })
247 }
248 Err(e) => Err(CliError::Internal(anyhow::anyhow!("{e}"))),
249 }
250 }
251
252 /// Resolve a sequence number to a hash.
253 fn resolve_sequence(&self, repo: &Repository, view_name: &str, seq: u64) -> CliResult<Hash> {

Callers 1

resolve_identifierMethod · 0.80

Calls 2

find_change_by_prefixMethod · 0.80

Tested by

no test coverage detected