`atomic view promote` over SetViewScope (SHARED).
(args: &super::view::Promote)
| 3682 | |
| 3683 | /// `atomic view promote` over SetViewScope (SHARED). |
| 3684 | pub fn view_promote(args: &super::view::Promote) -> CliResult<bool> { |
| 3685 | let Some(session) = Service::open()? else { |
| 3686 | return Ok(false); |
| 3687 | }; |
| 3688 | // No name = promote the current view; resolve it from the marker. |
| 3689 | let name = match &args.name { |
| 3690 | Some(name) => name.clone(), |
| 3691 | None => std::fs::read_to_string( |
| 3692 | crate::commands::find_repository_root()? |
| 3693 | .join(".atomic") |
| 3694 | .join("current_view"), |
| 3695 | ) |
| 3696 | .map(|s| s.trim().to_string()) |
| 3697 | .map_err(|_| CliError::InvalidArgument { |
| 3698 | message: "View name is required".to_string(), |
| 3699 | })?, |
| 3700 | }; |
| 3701 | let request = pb::SetViewScopeRequest { |
| 3702 | repository: Some(session.reference.clone()), |
| 3703 | meta: None, |
| 3704 | view: name.clone(), |
| 3705 | scope: pb::ViewScope::Shared as i32, |
| 3706 | expected_snapshot: None, |
| 3707 | }; |
| 3708 | session.set_view_scope(request)?; |
| 3709 | print_success(&format!("Promoted '{name}' to shared root view")); |
| 3710 | Ok(true) |
| 3711 | } |
| 3712 | |
| 3713 | /// `atomic restore` over Restore. The non-dry-run forms route; every |
| 3714 | /// dry-run form routes through the PreviewRestore arm the command |
no test coverage detected