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

Method maybe_switch

atomic-cli/src/commands/view/new.rs:314–337  ·  view source on GitHub ↗

Optionally switch to the new view and print hint. The switch coordinates the Git shadow exactly like `atomic view switch` does (CB-8A): the materialized view projects onto its mapped ref with the scope-correct HEAD policy and a verified checkpoint, so the next workspace entry stays anchored.

(
        &self,
        name: &str,
        repo: &mut Repository,
        working_copy: atomic_core::WorkingCopyId,
        repo_root: &std::path::Path,
    )

Source from the content-addressed store, hash-verified

312 /// ref with the scope-correct HEAD policy and a verified checkpoint, so
313 /// the next workspace entry stays anchored.
314 fn maybe_switch(
315 &self,
316 name: &str,
317 repo: &mut Repository,
318 working_copy: atomic_core::WorkingCopyId,
319 repo_root: &std::path::Path,
320 ) -> CliResult<()> {
321 if self.switch {
322 let result = repo
323 .switch_view(working_copy, name)
324 .map_err(CliError::Repository)?;
325 print_success(&format!(
326 "Switched to view: {} ({} files updated)",
327 style_view(name),
328 result.files_written,
329 ));
330 } else {
331 print_hint(&format!(
332 "Use 'atomic view switch {}' to switch to the new view",
333 name
334 ));
335 }
336 Ok(())
337 }
338}
339
340impl Command for New {

Callers 1

runMethod · 0.45

Calls 3

print_successFunction · 0.85
print_hintFunction · 0.85
switch_viewMethod · 0.45

Tested by

no test coverage detected