Parse a change hash from a string (full or abbreviated).
(repo: &Repository, hash_str: &str)
| 485 | |
| 486 | /// Parse a change hash from a string (full or abbreviated). |
| 487 | fn parse_change_hash(repo: &Repository, hash_str: &str) -> CliResult<Hash> { |
| 488 | // Try to parse as full hash first |
| 489 | if let Some(hash) = Hash::from_base32(hash_str.as_bytes()) { |
| 490 | return Ok(hash); |
| 491 | } |
| 492 | |
| 493 | // Try to find by prefix |
| 494 | if hash_str.len() >= 2 { |
| 495 | // Look through recent changes to find a match |
| 496 | match repo.find_change_by_prefix(hash_str) { |
| 497 | Ok(Some(hash)) => return Ok(hash), |
| 498 | Ok(None) => {} |
| 499 | Err(_e) => { |
| 500 | // Check if it's an ambiguous hash error |
| 501 | return Err(CliError::AmbiguousHash { |
| 502 | hash: hash_str.to_string(), |
| 503 | }); |
| 504 | } |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | Err(CliError::ChangeNotFound { |
| 509 | hash: hash_str.to_string(), |
| 510 | }) |
| 511 | } |
| 512 | |
| 513 | /// Print the outcome of a single insert operation. |
| 514 | fn print_insert_outcome( |
no test coverage detected