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)
| 738 | /// - The change is not found |
| 739 | /// - The hash prefix is ambiguous |
| 740 | fn run(&self) -> CliResult<()> { |
| 741 | // Find and open repository |
| 742 | let repo_root = find_repository_root()?; |
| 743 | let repo = Repository::open_readonly(&repo_root).map_err(|e| match e { |
| 744 | atomic_repository::RepositoryError::NotFound { path } => CliError::RepositoryNotFound { |
| 745 | searched_path: path.into(), |
| 746 | }, |
| 747 | atomic_repository::RepositoryError::ViewNotFound { name } => { |
| 748 | CliError::ViewNotFound { name } |
| 749 | } |
| 750 | other => CliError::Internal(anyhow::anyhow!("{}", other)), |
| 751 | })?; |
| 752 | |
| 753 | // Resolve identifier |
| 754 | let (hash, sequence) = self.resolve_identifier(&repo)?; |
| 755 | |
| 756 | // Load the change |
| 757 | let change = repo.load_change(&hash).map_err(|e| match e { |
| 758 | atomic_repository::RepositoryError::ChangeNotFound { hash } => { |
| 759 | CliError::ChangeNotFound { hash } |
| 760 | } |
| 761 | other => CliError::Internal(anyhow::anyhow!("{}", other)), |
| 762 | })?; |
| 763 | |
| 764 | // Print the change |
| 765 | self.print_change(&change, &hash, sequence, &repo); |
| 766 | |
| 767 | Ok(()) |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | // Helper Functions |