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)
| 759 | /// - The change is not found |
| 760 | /// - The hash prefix is ambiguous |
| 761 | fn run(&self) -> CliResult<()> { |
| 762 | // Find and open repository |
| 763 | let repo_root = find_repository_root()?; |
| 764 | let repo = Repository::open_readonly(&repo_root).map_err(|e| match e { |
| 765 | atomic_repository::RepositoryError::NotFound { path } => CliError::RepositoryNotFound { |
| 766 | searched_path: path.into(), |
| 767 | }, |
| 768 | atomic_repository::RepositoryError::ViewNotFound { name } => { |
| 769 | CliError::ViewNotFound { name } |
| 770 | } |
| 771 | other => CliError::Internal(anyhow::anyhow!("{}", other)), |
| 772 | })?; |
| 773 | |
| 774 | // Resolve identifier |
| 775 | let (hash, sequence) = self.resolve_identifier(&repo)?; |
| 776 | |
| 777 | // Load the change |
| 778 | let change = repo.load_change(&hash).map_err(|e| match e { |
| 779 | atomic_repository::RepositoryError::ChangeNotFound { hash } => { |
| 780 | CliError::ChangeNotFound { hash } |
| 781 | } |
| 782 | other => CliError::Internal(anyhow::anyhow!("{}", other)), |
| 783 | })?; |
| 784 | |
| 785 | // Print the change |
| 786 | self.print_change(&change, &hash, sequence, &repo); |
| 787 | |
| 788 | Ok(()) |
| 789 | } |
| 790 | } |
| 791 | |
| 792 | // Helper Functions |