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

Method run

atomic-cli/src/commands/view/promote.rs:46–88  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

44
45impl Command for Promote {
46 fn run(&self) -> CliResult<()> {
47 // Route through the daemon (SetViewScope SHARED).
48 if crate::commands::rpc::view_promote(self)? {
49 return Ok(());
50 }
51
52 let root = find_repository_root()?;
53 let mut repo = Repository::open_for_workspace_transaction(&root).map_err(|e| {
54 CliError::InvalidRepository {
55 reason: e.to_string(),
56 }
57 })?;
58 let workspace = enter_workspace(&mut repo, WorkspaceTxnMode::Reconcile)?;
59
60 let view_name = self
61 .name
62 .clone()
63 .unwrap_or_else(|| workspace.view().name.clone());
64
65 let info = repo
66 .get_view_info(&view_name)
67 .map_err(|e| CliError::Internal(e.into()))?;
68
69 if info.scope.is_shared() && info.parent_name.is_none() {
70 print_info(&format!(
71 "View '{}' is already a shared root view",
72 view_name
73 ));
74 return Ok(());
75 }
76
77 repo.set_view_scope(&view_name, ViewScope::Shared)
78 .map_err(|e| CliError::Internal(e.into()))?;
79
80 print_success(&format!(
81 "Promoted '{}' to shared root view (was {:?}, parent: {:?})",
82 view_name,
83 info.scope,
84 info.parent_name.as_deref().unwrap_or("none"),
85 ));
86
87 Ok(())
88 }
89}

Callers

nothing calls this directly

Calls 11

view_promoteFunction · 0.85
find_repository_rootFunction · 0.85
print_infoFunction · 0.85
print_successFunction · 0.85
get_view_infoMethod · 0.80
is_sharedMethod · 0.80
is_noneMethod · 0.80
enter_workspaceFunction · 0.50
cloneMethod · 0.45
viewMethod · 0.45
set_view_scopeMethod · 0.45

Tested by

no test coverage detected