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

Function change_hash_candidates

atomic-cli/src/commands/complete.rs:51–72  ·  view source on GitHub ↗

Change-hash completion candidates drawn from the change store. Commands that address a change by hash can reference *any* change that exists in the repo, so the candidate source is the change store rather than a single view's log. Returns `(base32_hash, optional_message)` pairs filtered by `prefix` and capped at [`MAX_CHANGE_CANDIDATES`]. Pure over the repository for unit testing.

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

Source from the content-addressed store, hash-verified

49/// filtered by `prefix` and capped at [`MAX_CHANGE_CANDIDATES`]. Pure over the
50/// repository for unit testing.
51pub(crate) fn change_hash_candidates(
52 repo: &Repository,
53 prefix: &str,
54) -> Vec<(String, Option<String>)> {
55 let mut out = Vec::new();
56 for result in repo.iter_changes() {
57 let Ok(hash) = result else { continue };
58 let b32 = hash.to_base32();
59 if !prefix.is_empty() && !b32.starts_with(prefix) {
60 continue;
61 }
62 let message = repo
63 .load_change(&hash)
64 .ok()
65 .map(|c| c.hashed.header.message.clone());
66 out.push((b32, message));
67 if out.len() >= MAX_CHANGE_CANDIDATES {
68 break;
69 }
70 }
71 out
72}
73
74/// Dynamic completer for view-name arguments.
75///

Callers 1

complete_change_hashesFunction · 0.85

Calls 7

iter_changesMethod · 0.45
to_base32Method · 0.45
is_emptyMethod · 0.45
load_changeMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected