(
repo: &Repository,
git_repo: &GitRepository,
view: &str,
)
| 1586 | const EPHEMERAL_PREFIX_LEN: usize = 7; |
| 1587 | |
| 1588 | fn resolve_head_policy( |
| 1589 | repo: &Repository, |
| 1590 | git_repo: &GitRepository, |
| 1591 | view: &str, |
| 1592 | ) -> CliResult<HeadPolicy> { |
| 1593 | let scope = repo |
| 1594 | .get_view_info(view) |
| 1595 | .map(|info| info.scope) |
| 1596 | .unwrap_or(atomic_core::pristine::ViewScope::Shared); |
| 1597 | // CB-10A: an explicit publication or rename reconciles the mapping first — |
| 1598 | // once a mapping row exists, its local ref is the authoritative projection |
| 1599 | // target (RFC §8.1). Absent mappings keep the pure scope policy. |
| 1600 | if let Ok(Some(mapping)) = repo.get_ref_mapping(view) { |
| 1601 | if let Some(local_ref) = mapping.local_ref.clone() { |
| 1602 | return match scope { |
| 1603 | atomic_core::pristine::ViewScope::Shared => Ok(HeadPolicy::SharedBranch { |
| 1604 | branch_ref: local_ref, |
| 1605 | }), |
| 1606 | atomic_core::pristine::ViewScope::Draft => Ok(HeadPolicy::Draft { |
| 1607 | view_ref: local_ref, |
| 1608 | }), |
| 1609 | }; |
| 1610 | } |
| 1611 | } |
| 1612 | match scope { |
| 1613 | atomic_core::pristine::ViewScope::Shared => Ok(HeadPolicy::SharedBranch { |
| 1614 | branch_ref: format!("refs/heads/{view}"), |
| 1615 | }), |
| 1616 | atomic_core::pristine::ViewScope::Draft => { |
| 1617 | if let Some(original) = ephemeral_original_commit(git_repo, view) { |
| 1618 | Ok(HeadPolicy::Ephemeral { original }) |
| 1619 | } else { |
| 1620 | Ok(HeadPolicy::Draft { |
| 1621 | view_ref: format!("refs/atomic/views/{view}"), |
| 1622 | }) |
| 1623 | } |
| 1624 | } |
| 1625 | } |
| 1626 | } |
| 1627 | |
| 1628 | /// Detect an ephemeral `git/<oid>` view and resolve the commit it adopted. |
| 1629 | /// |
no test coverage detected