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

Method run

atomic-cli/src/commands/record/command.rs:17–99  ·  view source on GitHub ↗

Execute the record command. # Process 1. Find and open the repository 2. Get the commit message (from argument, editor, or prompt) 3. Detect changes in the working copy 4. If --all, add untracked files 5. If --dry-run, display preview and exit 6. Create the change from modifications 7. Save the change to the store 8. Apply the change to the current view 9. Display the result

(&self)

Source from the content-addressed store, hash-verified

15 /// 8. Apply the change to the current view
16 /// 9. Display the result
17 fn run(&self) -> CliResult<()> {
18 // Find repository
19 let repo_root = find_repository_root()?;
20 let repo = Repository::open(&repo_root).map_err(CliError::Repository)?;
21
22 // Handle dry run
23 if self.dry_run {
24 return self.display_dry_run(&repo);
25 }
26
27 // Get commit message
28 let message = self.get_message()?;
29
30 // Resolve author from identity or command-line
31 let author = self.resolve_author()?;
32
33 // Build change header
34 let mut header_builder = ChangeHeader::builder().message(&message);
35
36 if let Some(author) = author {
37 header_builder = header_builder.author(author);
38 }
39
40 let header = header_builder.build();
41
42 // Build record options
43 let options = self.build_options()?;
44
45 // If --all, first add all untracked files
46 if self.all {
47 let status = repo
48 .status(StatusOptions::default())
49 .map_err(CliError::Repository)?;
50
51 for entry in status.untracked() {
52 let path = entry.path();
53 if let Err(e) = repo.add(path, Default::default()) {
54 print_warning(&format!("Failed to add '{}': {}", path.display(), e));
55 }
56 }
57 }
58
59 // Record the changes
60 let outcome = repo.record(header, options).map_err(|e| match e {
61 atomic_repository::record::RecordError::NothingToRecord => CliError::NothingToRecord,
62 atomic_repository::record::RecordError::NoFilesMatched => CliError::NothingToRecord,
63 atomic_repository::record::RecordError::FileNotFound { path } => {
64 CliError::FileNotFound {
65 path: PathBuf::from(path),
66 }
67 }
68 atomic_repository::record::RecordError::FileNotTracked { path } => {
69 CliError::FileNotTracked {
70 path: PathBuf::from(path),
71 }
72 }
73 other => CliError::Internal(anyhow::anyhow!("{}", other)),
74 })?;

Calls 15

find_repository_rootFunction · 0.85
print_warningFunction · 0.85
print_hintFunction · 0.85
resolve_authorMethod · 0.80
authorMethod · 0.80
build_optionsMethod · 0.80
untrackedMethod · 0.80
format_outcomeMethod · 0.80
skipped_filesMethod · 0.80
display_dry_runMethod · 0.45
get_messageMethod · 0.45
messageMethod · 0.45