Find a change by hash prefix.
(&self, repo: &Repository, hash_str: &str)
| 327 | |
| 328 | /// Find a change by hash prefix. |
| 329 | fn find_by_hash(&self, repo: &Repository, hash_str: &str) -> CliResult<u64> { |
| 330 | // Get history and search for matching hash |
| 331 | let history = repo |
| 332 | .log(HistoryOptions::default()) |
| 333 | .map_err(CliError::Repository)?; |
| 334 | |
| 335 | let hash_lower = hash_str.to_lowercase(); |
| 336 | let mut found: Option<u64> = None; |
| 337 | |
| 338 | for entry in history { |
| 339 | let entry_hash = entry.hash.to_base32().to_lowercase(); |
| 340 | if entry_hash.starts_with(&hash_lower) { |
| 341 | if found.is_some() { |
| 342 | return Err(CliError::AmbiguousHash { |
| 343 | hash: hash_str.to_string(), |
| 344 | }); |
| 345 | } |
| 346 | found = Some(entry.sequence); |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | found.ok_or_else(|| CliError::ChangeNotFound { |
| 351 | hash: hash_str.to_string(), |
| 352 | }) |
| 353 | } |
| 354 | |
| 355 | /// Get the message for the revised change. |
| 356 | fn get_message(&self, original_message: &str) -> CliResult<String> { |
no test coverage detected