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

Method run

atomic-cli/src/commands/diff/command.rs:546–847  ·  view source on GitHub ↗

Execute the diff command. This method: 1. Finds and opens the repository 2. Gets the status of the working copy 3. Computes diffs for modified files 4. Displays the diffs in the requested format

(&self)

Source from the content-addressed store, hash-verified

544 /// 3. Computes diffs for modified files
545 /// 4. Displays the diffs in the requested format
546 fn run(&self) -> CliResult<()> {
547 if crate::commands::rpc::diff(self)? {
548 return Ok(());
549 }
550
551 // Find the repository root
552 let repo_root = find_repository_root()?;
553
554 // Git-inspired, versioned staging diff (observation-only).
555 if self.git {
556 return self.run_git_diff(&repo_root);
557 }
558
559 // Open the repository and retain its stable workspace boundary for all diff work.
560 let mode = self.workspace_mode();
561 let mut repo = match mode {
562 WorkspaceTxnMode::Observe => crate::commands::open_readonly_repository(&repo_root),
563 WorkspaceTxnMode::Reconcile => Repository::open_for_workspace_transaction_wait(
564 &repo_root,
565 std::time::Duration::from_secs(10),
566 ),
567 WorkspaceTxnMode::Force => unreachable!("diff never forces workspace entry"),
568 }
569 .map_err(|e| CliError::InvalidRepository {
570 reason: e.to_string(),
571 })?;
572 let workspace = match mode {
573 WorkspaceTxnMode::Observe => match observe_workspace(&mut repo)? {
574 Ok(workspace) => Some(workspace),
575 Err(_) if self.change.is_some() => None,
576 Err(remediation) => return Err(remediation_error(remediation)),
577 },
578 WorkspaceTxnMode::Reconcile => Some(enter_workspace(&mut repo, mode)?),
579 WorkspaceTxnMode::Force => unreachable!("diff never forces workspace entry"),
580 };
581 // Parse algorithm
582 let algorithm = self.parse_algorithm()?;
583
584 // Get output configuration
585 let config = self.get_output_config();
586
587 // If --change is specified, show the content of that specific change
588 if let Some(change_ref) = &self.change {
589 return self.show_change_diff(&repo, change_ref, &config);
590 }
591 if self.snapshot {
592 let snapshot = repo
593 .snapshot_status(
594 workspace
595 .as_ref()
596 .expect("snapshot diff requires a ready Observe transaction")
597 .working_copy(),
598 )
599 .map_err(|error| CliError::Internal(error.into()))?;
600 let hash = snapshot.snapshot.or(snapshot.remainder).ok_or_else(|| {
601 CliError::InvalidArgument {
602 message: "this working copy has no active snapshot or remainder".to_string(),
603 }

Calls 15

find_repository_rootFunction · 0.85
open_readonly_repositoryFunction · 0.85
observe_workspaceFunction · 0.85
remediation_errorFunction · 0.85
deletedFunction · 0.85
removedFunction · 0.85
addedFunction · 0.85
read_contentFunction · 0.85
diff_textFunction · 0.85
run_git_diffMethod · 0.80
get_output_configMethod · 0.80
show_change_diffMethod · 0.80