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

Method run

atomic-cli/src/commands/log/command.rs:478–538  ·  view source on GitHub ↗

Execute the log command. This method: 1. Finds the repository root 2. Opens the repository 3. Queries history based on options 4. Formats and displays the results # Errors Returns a `CliError` if: - No repository is found - The specified view doesn't exist - Database errors occur

(&self)

Source from the content-addressed store, hash-verified

476 /// - The specified view doesn't exist
477 /// - Database errors occur
478 fn run(&self) -> CliResult<()> {
479 // Find and open repository
480 let repo_root = find_repository_root()?;
481 let repo = Repository::open_readonly(&repo_root).map_err(|e| match e {
482 atomic_repository::RepositoryError::NotFound { path } => CliError::RepositoryNotFound {
483 searched_path: path.into(),
484 },
485 atomic_repository::RepositoryError::ViewNotFound { name } => {
486 CliError::ViewNotFound { name }
487 }
488 other => CliError::Internal(anyhow::anyhow!("{}", other)),
489 })?;
490
491 // Build options
492 let options = self.build_history_options();
493 let view_name = self.view.as_deref().unwrap_or_else(|| repo.current_view());
494
495 // Get history
496 let entries = if self.reverse {
497 // Use forward log for reverse display (oldest first)
498 repo.log(options).map_err(|e| match e {
499 atomic_repository::RepositoryError::ViewNotFound { name } => {
500 CliError::ViewNotFound { name }
501 }
502 other => CliError::Internal(anyhow::anyhow!("{}", other)),
503 })?
504 } else {
505 // Use reverse log for default display (newest first)
506 repo.reverse_log(options).map_err(|e| match e {
507 atomic_repository::RepositoryError::ViewNotFound { name } => {
508 CliError::ViewNotFound { name }
509 }
510 other => CliError::Internal(anyhow::anyhow!("{}", other)),
511 })?
512 };
513
514 // Handle empty history
515 if entries.is_empty() {
516 self.print_empty_history(view_name);
517 return Ok(());
518 }
519
520 // Filter by path if specified (requires loading change content)
521 // Note: Path filtering is a placeholder - full implementation would
522 // require inspecting each change's hunks for the affected paths
523 if let Some(ref _path) = self.path {
524 // Path filtering would be implemented here
525 // For now, we show a warning and continue with unfiltered results
526 eprintln!(
527 "{}",
528 warning("Note: Path filtering is not yet fully implemented")
529 );
530 }
531
532 // Draft views now filter inherited changes by default (the
533 // repository layer compares against ancestor VIEW_CHANGES).
534 // Use `--all` to see the full log including inherited entries.
535 self.print_entries(&entries);

Calls 8

find_repository_rootFunction · 0.85
build_history_optionsMethod · 0.80
current_viewMethod · 0.80
logMethod · 0.80
reverse_logMethod · 0.80
print_empty_historyMethod · 0.80
print_entriesMethod · 0.80
is_emptyMethod · 0.45