Parse a change hash from a string (full or abbreviated).
(repo: &Repository, hash_str: &str)
| 724 | |
| 725 | /// Parse a change hash from a string (full or abbreviated). |
| 726 | fn parse_change_hash(repo: &Repository, hash_str: &str) -> CliResult<Hash> { |
| 727 | // Try to parse as full hash first |
| 728 | if let Some(hash) = Hash::from_base32(hash_str.as_bytes()) { |
| 729 | return Ok(hash); |
| 730 | } |
| 731 | |
| 732 | // Try to find by prefix |
| 733 | if hash_str.len() >= 2 { |
| 734 | // Look through recent changes to find a match |
| 735 | match repo.find_change_by_prefix(hash_str) { |
| 736 | Ok(Some(hash)) => return Ok(hash), |
| 737 | Ok(None) => {} |
| 738 | Err(_e) => { |
| 739 | // Check if it's an ambiguous hash error |
| 740 | return Err(CliError::AmbiguousHash { |
| 741 | hash: hash_str.to_string(), |
| 742 | }); |
| 743 | } |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | Err(CliError::ChangeNotFound { |
| 748 | hash: hash_str.to_string(), |
| 749 | }) |
| 750 | } |
| 751 | |
| 752 | /// Print the outcome of a single insert operation. |
| 753 | pub(crate) fn print_insert_outcome( |
no test coverage detected