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,
)
| 49 | /// filtered by `prefix` and capped at [`MAX_CHANGE_CANDIDATES`]. Pure over the |
| 50 | /// repository for unit testing. |
| 51 | pub(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 | /// |
no test coverage detected