Dynamic completer for change-hash arguments, annotating each hash with its commit message as the completion description.
(current: &OsStr)
| 89 | /// Dynamic completer for change-hash arguments, annotating each hash with its |
| 90 | /// commit message as the completion description. |
| 91 | pub(crate) fn complete_change_hashes(current: &OsStr) -> Vec<CompletionCandidate> { |
| 92 | let prefix = current.to_string_lossy(); |
| 93 | let Ok(repo) = require_repository(None) else { |
| 94 | return Vec::new(); |
| 95 | }; |
| 96 | change_hash_candidates(&repo, &prefix) |
| 97 | .into_iter() |
| 98 | .map(|(hash, msg)| { |
| 99 | let cand = CompletionCandidate::new(hash); |
| 100 | match msg { |
| 101 | Some(m) => cand.help(Some(m.into())), |
| 102 | None => cand, |
| 103 | } |
| 104 | }) |
| 105 | .collect() |
| 106 | } |
| 107 | |
| 108 | #[cfg(test)] |
| 109 | mod tests { |
nothing calls this directly
no test coverage detected