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

Method remove_files

libatomic/src/daemon/services.rs:1677–1864  ·  view source on GitHub ↗
(
        &self,
        request: Request<RemoveFilesRequest>,
    )

Source from the content-addressed store, hash-verified

1675 }
1676
1677 async fn remove_files(
1678 &self,
1679 request: Request<RemoveFilesRequest>,
1680 ) -> Result<Response<RemoveFilesResponse>, Status> {
1681 let request = request.into_inner();
1682 let handle = self
1683 .state
1684 .resolve(request.repository.as_ref().unwrap_or(&default_ref()))?;
1685 self.state.log_rpc("RemoveFiles", Some(&handle));
1686 // `keep_working_copy` guards the paths tracking untracks outright
1687 // (`--delete`); `untrack_only` is `--keep`, the `git rm --cached` shape
1688 // that stages a recorded path's untrack as pending intent with bytes
1689 // kept. The daemon mirrors the CLI's `git rm` matrix.
1690 let keep = request.keep_working_copy;
1691 let untrack_only = request.untrack_only;
1692 let gate_handle = handle.clone();
1693 let _gate = gate_handle.exclusive().await;
1694 let result = tokio::task::spawn_blocking(move || -> Result<RemoveFilesResponse, Status> {
1695 let (repo, workspace) = handle.workspace_repository(if request.dry_run {
1696 atomic_repository::WorkspaceTxnMode::Observe
1697 } else {
1698 atomic_repository::WorkspaceTxnMode::Reconcile
1699 })?;
1700 let working_copy = workspace.working_copy();
1701 let options = TrackingOptions {
1702 force: request.force,
1703 dry_run: request.dry_run,
1704 // `--keep` (`git rm --cached`): recorded paths stage their
1705 // untrack as per-view pending intent instead of deferring to a
1706 // working-copy deletion; the next record lands the delete with
1707 // the bytes kept.
1708 keep_recorded: untrack_only,
1709 ..TrackingOptions::default()
1710 };
1711 // Validate every path before applying any of it, as `git rm` does: a
1712 // refusal must never leave the other paths half-untracked. The plan
1713 // is the same classification a mutation applies, so a preview reports
1714 // exactly what the command would do.
1715 let mut refusals: Vec<RemovalRefusal> = Vec::new();
1716 let mut plan: Vec<(
1717 String,
1718 usize,
1719 Vec<std::path::PathBuf>,
1720 Vec<std::path::PathBuf>,
1721 )> = Vec::new();
1722 for path in &request.paths {
1723 // Normalize exactly like the CLI: absolute paths must be
1724 // inside the repository root and are made relative.
1725 let normalized = if std::path::Path::new(path).is_absolute() {
1726 match std::path::Path::new(path).strip_prefix(&handle.root) {
1727 Ok(rel) => rel.display().to_string(),
1728 Err(_) => {
1729 return Err(domain_status(
1730 ErrorCode::InvalidArgument,
1731 format!("path outside repository: {path}"),
1732 ))
1733 }
1734 }

Callers

nothing calls this directly

Calls 15

default_refFunction · 0.85
domain_statusFunction · 0.85
remove_from_working_copyFunction · 0.85
as_refMethod · 0.80
log_rpcMethod · 0.80
exclusiveMethod · 0.80
workspace_repositoryMethod · 0.80
displayMethod · 0.80
removeMethod · 0.65
into_innerMethod · 0.45
resolveMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected