The bare `atomic insert` promotion over InsertChanges — the promote arm resolves the current view, its parent, and the missing set server-side (the CLI holds no repository handle). The dry-run form renders the local preview from the pre-flight response; the real form pre-flights, runs the shared→shared confirmation client-side, then inserts through the same arm. Rendered with the local body's exac
(args: &super::insert::Insert)
| 4231 | /// inserts through the same arm. Rendered with the local body's exact |
| 4232 | /// print functions. |
| 4233 | pub fn insert_promote(args: &super::insert::Insert) -> CliResult<bool> { |
| 4234 | let Some(session) = Service::open()? else { |
| 4235 | return Ok(false); |
| 4236 | }; |
| 4237 | let mut request = insert_request( |
| 4238 | &session, |
| 4239 | Some(pb::insert_changes_request::Source::PromoteCurrentView( |
| 4240 | pb::PromoteCurrentView {}, |
| 4241 | )), |
| 4242 | args.view.clone(), |
| 4243 | args.allow_conflicts, |
| 4244 | args.deps, |
| 4245 | true, |
| 4246 | ); |
| 4247 | // The pre-flight read: source, parent, the missing set, and the |
| 4248 | // confirm-gate scopes — the same domain reads the local pre-flight |
| 4249 | // makes. The request is kept for the insert phase (the same arm |
| 4250 | // without the preview flag). |
| 4251 | let response = insert_rpc(&session, request.clone())?; |
| 4252 | let source = response.resolved_source_view.clone().unwrap_or_default(); |
| 4253 | let target = response.resolved_target_view.clone().unwrap_or_default(); |
| 4254 | let missing = response.inserted.len(); |
| 4255 | if missing == 0 { |
| 4256 | print_success(&format!( |
| 4257 | "Already even with '{target}' — nothing to insert." |
| 4258 | )); |
| 4259 | return Ok(true); |
| 4260 | } |
| 4261 | print_info(&format!( |
| 4262 | "Inserting {missing} change(s): {source} → {target}" |
| 4263 | )); |
| 4264 | if args.dry_run { |
| 4265 | // The local dry-run branch: the numbered missing list (full hash |
| 4266 | // plus the 50-byte-truncated message), then the dry-run notice. |
| 4267 | if let Some(review) = insert_review_approval(&response) { |
| 4268 | super::insert::print_review_approval(&review); |
| 4269 | } |
| 4270 | println!(); |
| 4271 | for (i, change) in response.inserted.iter().enumerate() { |
| 4272 | let hash = short_hash_full(&change.hash); |
| 4273 | match change.message.as_deref() { |
| 4274 | Some(message) if !message.is_empty() => println!( |
| 4275 | " {}. {} {}", |
| 4276 | i + 1, |
| 4277 | hash, |
| 4278 | crate::output::truncate_bytes(message, 50) |
| 4279 | ), |
| 4280 | _ => println!(" {}. {}", i + 1, hash), |
| 4281 | } |
| 4282 | } |
| 4283 | println!(); |
| 4284 | print_info("Dry run: no changes inserted. Re-run without --dry-run to insert."); |
| 4285 | return Ok(true); |
| 4286 | } |
| 4287 | // The shared→shared gate: the prompt runs client-side (interactive); |
| 4288 | // the wire carries the scopes the local pre-flight reads. |
| 4289 | if response.both_views_shared.unwrap_or(false) && !args.confirm { |
| 4290 | let prompt = format!( |
no test coverage detected