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

Method run

atomic-cli/src/commands/log/command.rs:482–542  ·  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

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