Execute the change command. This method: 1. Finds the repository root 2. Resolves the change identifier to a hash 3. Loads the change from the store 4. Formats and displays the change # Errors Returns a `CliError` if: - No repository is found - The change identifier is invalid - The change is not found - The hash prefix is ambiguous
(&self)
| 724 | /// - The change is not found |
| 725 | /// - The hash prefix is ambiguous |
| 726 | fn run(&self) -> CliResult<()> { |
| 727 | // Find and open repository |
| 728 | let repo_root = find_repository_root()?; |
| 729 | let repo = Repository::open_readonly(&repo_root).map_err(|e| match e { |
| 730 | atomic_repository::RepositoryError::NotFound { path } => CliError::RepositoryNotFound { |
| 731 | searched_path: path.into(), |
| 732 | }, |
| 733 | atomic_repository::RepositoryError::ViewNotFound { name } => { |
| 734 | CliError::ViewNotFound { name } |
| 735 | } |
| 736 | other => CliError::Internal(anyhow::anyhow!("{}", other)), |
| 737 | })?; |
| 738 | |
| 739 | // Resolve identifier |
| 740 | let (hash, sequence) = self.resolve_identifier(&repo)?; |
| 741 | |
| 742 | // Load the change |
| 743 | let change = repo.load_change(&hash).map_err(|e| match e { |
| 744 | atomic_repository::RepositoryError::ChangeNotFound { hash } => { |
| 745 | CliError::ChangeNotFound { hash } |
| 746 | } |
| 747 | other => CliError::Internal(anyhow::anyhow!("{}", other)), |
| 748 | })?; |
| 749 | |
| 750 | // Print the change |
| 751 | self.print_change(&change, &hash, sequence, &repo); |
| 752 | |
| 753 | Ok(()) |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | // Helper Functions |