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

Method resolve_branch_override

atomic-cli/src/commands/git/push.rs:641–663  ·  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

639 /// the name is used verbatim (never silently rewritten), so the caller is
640 /// told to pass an explicit `--branch` instead.
641 fn resolve_branch_override(
642 explicit: Option<&str>,
643 scope: ViewScope,
644 view: &str,
645 ) -> CliResult<Option<String>> {
646 if let Some(branch) = explicit {
647 return Ok(Some(branch.to_string()));
648 }
649 if scope.is_draft() {
650 let refname = format!("refs/heads/{}", view);
651 if !git2::Reference::is_valid_name(&refname) {
652 return Err(CliError::GitError {
653 message: format!(
654 "Draft view '{}' is not a valid git branch name; \
655 pass --branch to choose an explicit target.",
656 view
657 ),
658 });
659 }
660 return Ok(Some(view.to_string()));
661 }
662 Ok(None)
663 }
664
665 /// The git branch the push will land on: the resolved `override_branch`
666 /// (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