Resolve the `(source, target)` view pair a triage run operates on. Both arguments are optional so the common gesture needs no arguments at all: the source is the current view and the target is that view's direct parent — the same default `atomic insert` uses for a bare promote. `arg` names the argument a name came from so an unknown view can be reported against it. # Errors Returns [`CliError::
(
repo: &Repository,
feature: Option<&str>,
into: Option<&str>,
)
| 384 | /// exist, or if the target was omitted and the source is a root view (nothing |
| 385 | /// to promote into). |
| 386 | fn resolve_views( |
| 387 | repo: &Repository, |
| 388 | feature: Option<&str>, |
| 389 | into: Option<&str>, |
| 390 | ) -> CliResult<(String, String)> { |
| 391 | let source = match feature { |
| 392 | Some(name) => { |
| 393 | require_view(repo, name, "<VIEW>")?; |
| 394 | name.to_string() |
| 395 | } |
| 396 | None => repo.current_view().to_string(), |
| 397 | }; |
| 398 | |
| 399 | let target = match into { |
| 400 | Some(name) => { |
| 401 | require_view(repo, name, "--into")?; |
| 402 | name.to_string() |
| 403 | } |
| 404 | None => match repo.parent_change_count(&source) { |
| 405 | Ok(Some((parent, _))) => parent, |
| 406 | Ok(None) => { |
| 407 | return Err(CliError::InvalidArgument { |
| 408 | message: format!( |
| 409 | "'{source}' is a root view — it has no parent to promote into.\n \ |
| 410 | Pass --into <view> to choose a target (see 'atomic view list')." |
| 411 | ), |
| 412 | }) |
| 413 | } |
| 414 | Err(RepositoryError::ViewNotFound { name }) => { |
| 415 | return Err(unknown_view(repo, &name, "<VIEW>")) |
| 416 | } |
| 417 | Err(e) => return Err(CliError::Repository(e)), |
| 418 | }, |
| 419 | }; |
| 420 | |
| 421 | Ok((source, target)) |
| 422 | } |
| 423 | |
| 424 | /// Fail with an actionable message when a triage view argument names a view |
| 425 | /// that does not exist. |