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

Method run

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

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

Calls 9

find_repository_rootFunction · 0.85
open_readonly_repositoryFunction · 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