Parse a change hash from a string (full or abbreviated).
(repo: &Repository, hash_str: &str)
| 711 | |
| 712 | /// Parse a change hash from a string (full or abbreviated). |
| 713 | fn parse_change_hash(repo: &Repository, hash_str: &str) -> CliResult<Hash> { |
| 714 | // Try to parse as full hash first |
| 715 | if let Some(hash) = Hash::from_base32(hash_str.as_bytes()) { |
| 716 | return Ok(hash); |
| 717 | } |
| 718 | |
| 719 | // Try to find by prefix |
| 720 | if hash_str.len() >= 2 { |
| 721 | // Look through recent changes to find a match |
| 722 | match repo.find_change_by_prefix(hash_str) { |
| 723 | Ok(Some(hash)) => return Ok(hash), |
| 724 | Ok(None) => {} |
| 725 | Err(_e) => { |
| 726 | // Check if it's an ambiguous hash error |
| 727 | return Err(CliError::AmbiguousHash { |
| 728 | hash: hash_str.to_string(), |
| 729 | }); |
| 730 | } |
| 731 | } |
| 732 | } |
| 733 | |
| 734 | Err(CliError::ChangeNotFound { |
| 735 | hash: hash_str.to_string(), |
| 736 | }) |
| 737 | } |
| 738 | |
| 739 | /// Print the outcome of a single insert operation. |
| 740 | pub(crate) fn print_insert_outcome( |
no test coverage detected