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

Method run

atomic-cli/src/commands/remove.rs:254–468  ·  view source on GitHub ↗

Execute the remove command. # Process 1. Find and open the repository inside a workspace transaction 2. Classify every requested path read-only: a staged binding tracking may delete, a recorded path that needs a delete change, or a refusal 3. Refuse the whole request before applying anything if any path cannot be untracked this way, as `git rm` validates before it removes 4. Report the plan and

(&self)

Source from the content-addressed store, hash-verified

252 /// working copy
253 /// 6. Summarize, naming the `atomic record` that completes the untrack
254 fn run(&self) -> CliResult<()> {
255 // Route through the service when reachable: `Mode::Local` runs the same
256 // handler in-process, and `Mode::Reactor` the serving daemon. The body
257 // below runs only where no service can resolve the repository (a remote
258 // sandbox, which executes over its local cache).
259 if crate::commands::rpc::remove(self)? {
260 return Ok(());
261 }
262
263 // Find repository
264 let repo_root = find_repository_root()?;
265 let mode = if self.dry_run {
266 WorkspaceTxnMode::Observe
267 } else {
268 WorkspaceTxnMode::Reconcile
269 };
270 let mut repo = if self.dry_run {
271 Repository::open_readonly(&repo_root)
272 } else {
273 Repository::open_for_workspace_transaction(&repo_root)
274 }
275 .map_err(CliError::Repository)?;
276 let workspace = enter_workspace(&mut repo, mode)?;
277 let working_copy = workspace.working_copy();
278
279 let options = self.to_tracking_options();
280
281 // Staged paths are untracked by `repo.remove`; recorded paths come back
282 // in `pending_deletions` and need their working-copy bytes deleted plus a
283 // recorded delete. `git rm` validates the whole request before applying
284 // any of it, so the classification runs first, read-only, over every path:
285 // a refusal never leaves the other paths half-untracked.
286 let preview_options = TrackingOptions {
287 dry_run: true,
288 ..options.clone()
289 };
290 let mut targets: Vec<String> = Vec::new();
291 let mut plan_untrack = 0usize;
292 let mut plan_delete: Vec<PathBuf> = Vec::new();
293 let mut plan_mark = 0usize;
294 let mut dirty_guarded: Vec<String> = Vec::new();
295 let mut total_errors = 0usize;
296
297 for path in &self.paths {
298 // Normalize path relative to repo root
299 let normalized = if std::path::Path::new(path).is_absolute() {
300 match std::path::Path::new(path).strip_prefix(&repo_root) {
301 Ok(rel) => rel.to_string_lossy().to_string(),
302 Err(_) => {
303 print_warning(&format!("Path outside repository: {}", path));
304 total_errors += 1;
305 continue;
306 }
307 }
308 } else {
309 path.clone()
310 };
311 targets.push(normalized.clone());

Callers

nothing calls this directly

Calls 15

find_repository_rootFunction · 0.85
print_warningFunction · 0.85
refusal_messageFunction · 0.85
print_hintFunction · 0.85
print_failed_deletionsFunction · 0.85
print_successFunction · 0.85
failed_deletions_errorFunction · 0.85
to_tracking_optionsMethod · 0.80
deletes_staged_pathsMethod · 0.80
extendMethod · 0.80
removeFunction · 0.70
enter_workspaceFunction · 0.70

Tested by

no test coverage detected