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

Method resolve_branch_override

atomic-cli/src/commands/git/push.rs:429–451  ·  view source on GitHub ↗

Resolve the git branch this push targets, applying draft-view auto-mapping. Explicit `--branch` (`explicit`) always wins. Otherwise, when the current Atomic view is a draft, the target defaults to a git branch named after the view, so each draft publishes to its own remote ref (created on first push). Shared views keep the historical behavior of landing on the current git branch, signalled by ret

(
        explicit: Option<&str>,
        scope: ViewScope,
        view: &str,
    )

Source from the content-addressed store, hash-verified

427 /// the name is used verbatim (never silently rewritten), so the caller is
428 /// told to pass an explicit `--branch` instead.
429 fn resolve_branch_override(
430 explicit: Option<&str>,
431 scope: ViewScope,
432 view: &str,
433 ) -> CliResult<Option<String>> {
434 if let Some(branch) = explicit {
435 return Ok(Some(branch.to_string()));
436 }
437 if scope.is_draft() {
438 let refname = format!("refs/heads/{}", view);
439 if !git2::Reference::is_valid_name(&refname) {
440 return Err(CliError::GitError {
441 message: format!(
442 "Draft view '{}' is not a valid git branch name; \
443 pass --branch to choose an explicit target.",
444 view
445 ),
446 });
447 }
448 return Ok(Some(view.to_string()));
449 }
450 Ok(None)
451 }
452
453 /// The git branch the push will land on: the resolved `override_branch`
454 /// (explicit `--branch` or a draft view's mapped branch) if present, else

Callers

nothing calls this directly

Calls 1

is_draftMethod · 0.45

Tested by

no test coverage detected