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

Method run

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

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

Calls 14

find_repository_rootFunction · 0.85
remote_cache_rootFunction · 0.85
openFunction · 0.85
open_readonly_repositoryFunction · 0.85
is_dirMethod · 0.80
build_history_optionsMethod · 0.80
reverse_logMethod · 0.80
print_empty_historyMethod · 0.80
print_entriesMethod · 0.80
logFunction · 0.50
current_viewMethod · 0.45