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

Function resolve_views

atomic-cli/src/commands/triage/mod.rs:386–422  ·  view source on GitHub ↗

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>,
)

Source from the content-addressed store, hash-verified

384/// exist, or if the target was omitted and the source is a root view (nothing
385/// to promote into).
386fn 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.

Calls 5

require_viewFunction · 0.85
unknown_viewFunction · 0.85
RepositoryClass · 0.85
parent_change_countMethod · 0.80
current_viewMethod · 0.45