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

Function resolve_views

atomic-cli/src/commands/triage/mod.rs:279–315  ·  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

277/// exist, or if the target was omitted and the source is a root view (nothing
278/// to promote into).
279fn resolve_views(
280 repo: &Repository,
281 feature: Option<&str>,
282 into: Option<&str>,
283) -> CliResult<(String, String)> {
284 let source = match feature {
285 Some(name) => {
286 require_view(repo, name, "<VIEW>")?;
287 name.to_string()
288 }
289 None => repo.current_view().to_string(),
290 };
291
292 let target = match into {
293 Some(name) => {
294 require_view(repo, name, "--into")?;
295 name.to_string()
296 }
297 None => match repo.parent_change_count(&source) {
298 Ok(Some((parent, _))) => parent,
299 Ok(None) => {
300 return Err(CliError::InvalidArgument {
301 message: format!(
302 "'{source}' is a root view — it has no parent to promote into.\n \
303 Pass --into <view> to choose a target (see 'atomic view list')."
304 ),
305 })
306 }
307 Err(RepositoryError::ViewNotFound { name }) => {
308 return Err(unknown_view(repo, &name, "<VIEW>"))
309 }
310 Err(e) => return Err(CliError::Repository(e)),
311 },
312 };
313
314 Ok((source, target))
315}
316
317/// Fail with an actionable message when a triage view argument names a view
318/// 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