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)
| 782 | /// - The change is not found |
| 783 | /// - The hash prefix is ambiguous |
| 784 | fn run(&self) -> CliResult<()> { |
| 785 | // Find and open repository |
| 786 | let repo_root = find_repository_root()?; |
| 787 | let repo = Repository::open_readonly(&repo_root).map_err(|e| match e { |
| 788 | atomic_repository::RepositoryError::NotFound { path } => CliError::RepositoryNotFound { |
| 789 | searched_path: path.into(), |
| 790 | }, |
| 791 | atomic_repository::RepositoryError::ViewNotFound { name } => { |
| 792 | CliError::ViewNotFound { name } |
| 793 | } |
| 794 | other => CliError::Internal(anyhow::anyhow!("{}", other)), |
| 795 | })?; |
| 796 | |
| 797 | // Resolve identifier |
| 798 | let (hash, sequence) = self.resolve_identifier(&repo)?; |
| 799 | |
| 800 | // Load the change |
| 801 | let change = repo.load_change(&hash).map_err(|e| match e { |
| 802 | atomic_repository::RepositoryError::ChangeNotFound { hash } => { |
| 803 | CliError::ChangeNotFound { hash } |
| 804 | } |
| 805 | other => CliError::Internal(anyhow::anyhow!("{}", other)), |
| 806 | })?; |
| 807 | |
| 808 | // Print the change |
| 809 | self.print_change(&change, &hash, sequence, &repo); |
| 810 | |
| 811 | Ok(()) |
| 812 | } |
| 813 | } |
| 814 | |
| 815 | // Helper Functions |