MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / run

Method run

atomic-cli/src/commands/change/command.rs:468–514  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

466 /// - The change is not found
467 /// - The hash prefix is ambiguous
468 fn run(&self) -> CliResult<()> {
469 if crate::commands::rpc::change(self)? {
470 return Ok(());
471 }
472
473 // Find and open repository
474 let repo_root = find_repository_root()?;
475 let repo = crate::commands::open_readonly_repository(&repo_root).map_err(|e| match e {
476 atomic_repository::RepositoryError::NotFound { path } => CliError::RepositoryNotFound {
477 searched_path: path.into(),
478 },
479 atomic_repository::RepositoryError::ViewNotFound { name } => {
480 CliError::ViewNotFound { name }
481 }
482 other => CliError::Internal(anyhow::anyhow!("{}", other)),
483 })?;
484
485 // Resolve identifier
486 let (hash, sequence) = self.resolve_identifier(&repo)?;
487
488 // Load the change
489 let change = repo.load_change(&hash).map_err(|e| match e {
490 atomic_repository::RepositoryError::ChangeNotFound { hash } => {
491 CliError::ChangeNotFound { hash }
492 }
493 other => CliError::Internal(anyhow::anyhow!("{}", other)),
494 })?;
495
496 // The render data from the repository (dep messages for --show-deps)
497 let mut data = ChangeRenderData::from_repo(&repo, &hash);
498 if self.show_deps {
499 for dep_hash in &change.hashed.dependencies {
500 let message = repo
501 .load_change(dep_hash)
502 .ok()
503 .and_then(|c| c.hashed.header.message.lines().next().map(str::to_string));
504 if let Some(message) = message {
505 data.dep_messages.insert(*dep_hash, message);
506 }
507 }
508 }
509
510 // Print the change
511 self.print_change(&change, &hash, sequence, &data);
512
513 Ok(())
514 }
515}
516
517// Helper Functions

Calls 10

find_repository_rootFunction · 0.85
open_readonly_repositoryFunction · 0.85
resolve_identifierMethod · 0.80
print_changeMethod · 0.80
changeFunction · 0.50
load_changeMethod · 0.45
okMethod · 0.45
nextMethod · 0.45
linesMethod · 0.45
insertMethod · 0.45