Resolve a hash prefix to a full hash.
(
&self,
repo: &Repository,
view_name: &str,
prefix: &str,
)
| 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> { |
no test coverage detected