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,
)
| 384 | /// the name is used verbatim (never silently rewritten), so the caller is |
| 385 | /// told to pass an explicit `--branch` instead. |
| 386 | fn resolve_branch_override( |
| 387 | explicit: Option<&str>, |
| 388 | scope: ViewScope, |
| 389 | view: &str, |
| 390 | ) -> CliResult<Option<String>> { |
| 391 | if let Some(branch) = explicit { |
| 392 | return Ok(Some(branch.to_string())); |
| 393 | } |
| 394 | if scope.is_draft() { |
| 395 | let refname = format!("refs/heads/{}", view); |
| 396 | if !git2::Reference::is_valid_name(&refname) { |
| 397 | return Err(CliError::GitError { |
| 398 | message: format!( |
| 399 | "Draft view '{}' is not a valid git branch name; \ |
| 400 | pass --branch to choose an explicit target.", |
| 401 | view |
| 402 | ), |
| 403 | }); |
| 404 | } |
| 405 | return Ok(Some(view.to_string())); |
| 406 | } |
| 407 | Ok(None) |
| 408 | } |
| 409 | |
| 410 | /// The git branch the push will land on: the resolved `override_branch` |
| 411 | /// (explicit `--branch` or a draft view's mapped branch) if present, else |