Parse a change hash from a string (full or abbreviated).
(repo: &Repository, hash_str: &str)
| 633 | |
| 634 | /// Parse a change hash from a string (full or abbreviated). |
| 635 | fn parse_change_hash(repo: &Repository, hash_str: &str) -> CliResult<Hash> { |
| 636 | // Try to parse as full hash first |
| 637 | if let Some(hash) = Hash::from_base32(hash_str.as_bytes()) { |
| 638 | return Ok(hash); |
| 639 | } |
| 640 | |
| 641 | // Try to find by prefix |
| 642 | if hash_str.len() >= 2 { |
| 643 | // Look through recent changes to find a match |
| 644 | match repo.find_change_by_prefix(hash_str) { |
| 645 | Ok(Some(hash)) => return Ok(hash), |
| 646 | Ok(None) => {} |
| 647 | Err(_e) => { |
| 648 | // Check if it's an ambiguous hash error |
| 649 | return Err(CliError::AmbiguousHash { |
| 650 | hash: hash_str.to_string(), |
| 651 | }); |
| 652 | } |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | Err(CliError::ChangeNotFound { |
| 657 | hash: hash_str.to_string(), |
| 658 | }) |
| 659 | } |
| 660 | |
| 661 | /// Print the outcome of a single insert operation. |
| 662 | fn print_insert_outcome( |
no test coverage detected