`atomic add` over AddFiles — every form: dry-run/force/directory/ no-recursive ride the wire, and internal `.atomic` paths route too (the repository's ignore rules treat them like any other ignored path — the tolerant per-path report carries the skip).
(args: &super::add::Add)
| 538 | /// (the repository's ignore rules treat them like any other ignored |
| 539 | /// path — the tolerant per-path report carries the skip). |
| 540 | pub fn add(args: &super::add::Add) -> CliResult<bool> { |
| 541 | let Some(session) = Service::open()? else { |
| 542 | return Ok(false); |
| 543 | }; |
| 544 | let root = crate::commands::find_repository_root()?; |
| 545 | let paths = if args.all { |
| 546 | // `add --all` composes an untracked read first — the same read the |
| 547 | // CLI does today, over the service layer. |
| 548 | let request = pb::StatusRequest { |
| 549 | repository: Some(session.reference.clone()), |
| 550 | options: None, |
| 551 | }; |
| 552 | let status = session.status(request)?; |
| 553 | status |
| 554 | .files |
| 555 | .iter() |
| 556 | .filter(|file| file.status == pb::FileStatus::Untracked as i32) |
| 557 | .map(|file| file.path.clone()) |
| 558 | .collect() |
| 559 | } else { |
| 560 | args.files.clone() |
| 561 | }; |
| 562 | let request = pb::AddFilesRequest { |
| 563 | repository: Some(session.reference.clone()), |
| 564 | meta: request_meta(), |
| 565 | paths: paths.iter().map(|path| relativize(path, &root)).collect(), |
| 566 | expected: None, |
| 567 | dry_run: args.dry_run, |
| 568 | force: args.force, |
| 569 | directory: args.directory, |
| 570 | no_recursive: args.no_recursive, |
| 571 | }; |
| 572 | let response = session.add_files(request)?; |
| 573 | for path in &paths { |
| 574 | println!("Adding: {path}"); |
| 575 | } |
| 576 | if response.dry_run { |
| 577 | for path in &response.would_add { |
| 578 | println!("Would add: {path}"); |
| 579 | } |
| 580 | for path in &response.skipped_tracked { |
| 581 | println!("Skipping: {path} (already tracked)"); |
| 582 | } |
| 583 | for path in &response.skipped_ignored { |
| 584 | println!("Skipping: {path} (ignored)"); |
| 585 | } |
| 586 | for path in &response.failed_paths { |
| 587 | println!("Error: {path} - could not be added"); |
| 588 | } |
| 589 | println!("Would add {} file(s)", response.would_add.len()); |
| 590 | return Ok(true); |
| 591 | } |
| 592 | if response.tracked > 0 { |
| 593 | let requested = paths |
| 594 | .iter() |
| 595 | .map(std::path::PathBuf::from) |
| 596 | .collect::<Vec<_>>(); |
| 597 | if let Err(error) = super::add::finish_service_add(&root, &requested) { |