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

Function insert_single

atomic-cli/src/commands/rpc.rs:4065–4109  ·  view source on GitHub ↗

`atomic insert ` over InsertChanges — the raw reference rides the single-ref arm (the handler resolves it with the local resolver's semantics); both --deps forms (the escape hatch rides apply_dependencies). Rendered with the local single-insert body's exact print functions.

(
    change: &str,
    view: Option<String>,
    allow_conflicts: bool,
    deps: bool,
)

Source from the content-addressed store, hash-verified

4063/// apply_dependencies). Rendered with the local single-insert body's
4064/// exact print functions.
4065pub fn insert_single(
4066 change: &str,
4067 view: Option<String>,
4068 allow_conflicts: bool,
4069 deps: bool,
4070) -> CliResult<bool> {
4071 let Some(session) = Service::open()? else {
4072 return Ok(false);
4073 };
4074 let request = insert_request(
4075 &session,
4076 Some(pb::insert_changes_request::Source::SingleRef(
4077 change.to_string(),
4078 )),
4079 view,
4080 allow_conflicts,
4081 deps,
4082 false,
4083 );
4084 let response = insert_rpc(&session, request)?;
4085 let hash = response
4086 .resolved_change
4087 .as_ref()
4088 .and_then(|h| h.value.clone().try_into().ok())
4089 .map(Merkle);
4090 if let Some(hash) = hash {
4091 print_info(&format!(
4092 "Inserting change {}...",
4093 crate::commands::format_hash(&hash, true)
4094 ));
4095 }
4096 let applied = insert_applied_hashes(&response);
4097 let new_state = response
4098 .new_state
4099 .as_ref()
4100 .and_then(|h| h.value.clone().try_into().ok())
4101 .map(Merkle)
4102 .unwrap_or_default();
4103 super::insert::print_insert_outcome(&applied, new_state, response.has_conflicts);
4104 if let Some(review) = insert_review_approval(&response) {
4105 super::insert::print_review_approval(&review);
4106 }
4107 print_insert_refresh(&response, false);
4108 Ok(true)
4109}
4110
4111/// `atomic insert view <source> [--to <target>] [-n]` over InsertChanges —
4112/// both --deps forms and the dry-run preview (the handler computes the

Callers 1

runMethod · 0.85

Calls 12

insert_requestFunction · 0.85
insert_rpcFunction · 0.85
print_infoFunction · 0.85
insert_applied_hashesFunction · 0.85
print_insert_outcomeFunction · 0.85
insert_review_approvalFunction · 0.85
print_review_approvalFunction · 0.85
print_insert_refreshFunction · 0.85
as_refMethod · 0.80
openFunction · 0.50
okMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected