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

Function resolve_triage_views

libatomic/src/daemon/services_triage.rs:29–64  ·  view source on GitHub ↗

The local `resolve_views` semantics — the (feature, target) pair with the same defaults (current view; its parent) and the same errors (unknown view, root view without --into).

(
    repo: &Repository,
    feature: Option<&str>,
    into: Option<&str>,
)

Source from the content-addressed store, hash-verified

27/// the same defaults (current view; its parent) and the same errors
28/// (unknown view, root view without --into).
29fn resolve_triage_views(
30 repo: &Repository,
31 feature: Option<&str>,
32 into: Option<&str>,
33) -> Result<(String, String), Status> {
34 let source = match feature {
35 Some(name) => {
36 require_triage_view(repo, name, "<VIEW>")?;
37 name.to_string()
38 }
39 None => repo.current_view().to_string(),
40 };
41 let target = match into {
42 Some(name) => {
43 require_triage_view(repo, name, "--into")?;
44 name.to_string()
45 }
46 None => match repo.parent_change_count(&source) {
47 Ok(Some((parent, _))) => parent,
48 Ok(None) => {
49 return Err(domain_status(
50 ErrorCode::InvalidArgument,
51 format!(
52 "'{source}' is a root view — it has no parent to promote into.\n \
53 Pass --into <view> to choose a target (see 'atomic view list')."
54 ),
55 ));
56 }
57 Err(atomic_repository::RepositoryError::ViewNotFound { name }) => {
58 return Err(unknown_triage_view(repo, &name, "<VIEW>"));
59 }
60 Err(error) => return Err(repository_error(error)),
61 },
62 };
63 Ok((source, target))
64}
65
66fn require_triage_view(repo: &Repository, name: &str, arg: &str) -> Result<(), Status> {
67 if repo.view_exists(name).map_err(repository_error)? {

Callers 2

Calls 6

require_triage_viewFunction · 0.85
domain_statusFunction · 0.85
unknown_triage_viewFunction · 0.85
parent_change_countMethod · 0.80
repository_errorFunction · 0.70
current_viewMethod · 0.45

Tested by

no test coverage detected