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>,
)
| 27 | /// the same defaults (current view; its parent) and the same errors |
| 28 | /// (unknown view, root view without --into). |
| 29 | fn 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 | |
| 66 | fn require_triage_view(repo: &Repository, name: &str, arg: &str) -> Result<(), Status> { |
| 67 | if repo.view_exists(name).map_err(repository_error)? { |
no test coverage detected