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

Method run

atomic-cli/src/commands/insert.rs:211–297  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

209
210impl crate::commands::Command for Insert {
211 fn run(&self) -> CliResult<()> {
212 // Route EVERY form through the service layer — BEFORE any local
213 // repository open (the routed path must never touch redb). The
214 // --deps escape hatch rides apply_dependencies (the handler
215 // applies or skips the closure server-side); the dry-run previews
216 // ride the request's dry_run flag (the handler computes the plan
217 // with the same domain call); the tag --from-view override rides
218 // tag_from_view; multi-pick references resolve handler-side with
219 // the resolver's semantics; the bare promotion resolves source
220 // and parent through the promote arm (the pre-flight read and the
221 // confirmed insert are the same RPC's two phases).
222 let route_ok = match &self.command {
223 Some(InsertSubcommand::View(args)) => crate::commands::rpc::insert_from_view(
224 &args.from_view,
225 args.to_view.clone(),
226 args.allow_conflicts,
227 args.deps,
228 args.dry_run,
229 )?,
230 Some(InsertSubcommand::Tag(args)) => crate::commands::rpc::insert_up_to_tag(
231 &args.tag_name,
232 args.from_view.clone(),
233 args.to_view.clone(),
234 args.allow_conflicts,
235 args.deps,
236 args.dry_run,
237 )?,
238 Some(InsertSubcommand::Change(args)) => crate::commands::rpc::insert_changes(
239 &args.changes,
240 args.to_view.clone(),
241 args.allow_conflicts,
242 )?,
243 None if self.change.is_some() => crate::commands::rpc::insert_single(
244 self.change.as_deref().expect("guarded above"),
245 self.view.clone(),
246 self.allow_conflicts,
247 self.deps,
248 )?,
249 None => crate::commands::rpc::insert_promote(self)?,
250 Some(InsertSubcommand::Preview(args)) => crate::commands::rpc::insert_preview(
251 &args.from_view,
252 args.to_view.clone(),
253 args.up_to_tag.clone(),
254 )?,
255 };
256 if route_ok {
257 return Ok(());
258 }
259 let repo_path = self.repository.as_ref().map(std::path::Path::new);
260 let repo_root = match repo_path {
261 Some(path) => find_repository_root_from(path)?,
262 None => find_repository_root()?,
263 };
264
265 let mode = self.workspace_mode();
266 let mut repo = match mode {
267 WorkspaceTxnMode::Observe => require_repository_readonly(Some(&repo_root)),
268 WorkspaceTxnMode::Reconcile => {

Callers

nothing calls this directly

Calls 15

insert_from_viewFunction · 0.85
insert_up_to_tagFunction · 0.85
insert_changesFunction · 0.85
insert_singleFunction · 0.85
insert_promoteFunction · 0.85
insert_previewFunction · 0.85
find_repository_rootFunction · 0.85
run_view_insertFunction · 0.85
run_tagFunction · 0.85
run_change_insertFunction · 0.85

Tested by

no test coverage detected