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

Method run

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

472 /// - The specified view doesn't exist
473 /// - Database errors occur
474 fn run(&self) -> CliResult<()> {
475 // Find and open repository
476 let repo_root = find_repository_root()?;
477 let repo = Repository::open_readonly(&repo_root).map_err(|e| match e {
478 atomic_repository::RepositoryError::NotFound { path } => CliError::RepositoryNotFound {
479 searched_path: path.into(),
480 },
481 atomic_repository::RepositoryError::ViewNotFound { name } => {
482 CliError::ViewNotFound { name }
483 }
484 other => CliError::Internal(anyhow::anyhow!("{}", other)),
485 })?;
486
487 // Build options
488 let options = self.build_history_options();
489 let view_name = self.view.as_deref().unwrap_or_else(|| repo.current_view());
490
491 // Get history
492 let entries = if self.reverse {
493 // Use forward log for reverse display (oldest first)
494 repo.log(options).map_err(|e| match e {
495 atomic_repository::RepositoryError::ViewNotFound { name } => {
496 CliError::ViewNotFound { name }
497 }
498 other => CliError::Internal(anyhow::anyhow!("{}", other)),
499 })?
500 } else {
501 // Use reverse log for default display (newest first)
502 repo.reverse_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 };
509
510 // Handle empty history
511 if entries.is_empty() {
512 self.print_empty_history(view_name);
513 return Ok(());
514 }
515
516 // Filter by path if specified (requires loading change content)
517 // Note: Path filtering is a placeholder - full implementation would
518 // require inspecting each change's hunks for the affected paths
519 if let Some(ref _path) = self.path {
520 // Path filtering would be implemented here
521 // For now, we show a warning and continue with unfiltered results
522 eprintln!(
523 "{}",
524 warning("Note: Path filtering is not yet fully implemented")
525 );
526 }
527
528 // Show all entries in VIEW_CHANGES for this view.
529 //
530 // Previous draft-view filtering used `parent_change_count` which
531 // reads the parent's *live* change_count. That counter moves as

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