(
repo: &Repository,
git_repo: &GitRepository,
view: &str,
)
| 1398 | const EPHEMERAL_PREFIX_LEN: usize = 7; |
| 1399 | |
| 1400 | fn resolve_head_policy( |
| 1401 | repo: &Repository, |
| 1402 | git_repo: &GitRepository, |
| 1403 | view: &str, |
| 1404 | ) -> CliResult<HeadPolicy> { |
| 1405 | let scope = repo |
| 1406 | .get_view_info(view) |
| 1407 | .map(|info| info.scope) |
| 1408 | .unwrap_or(atomic_core::pristine::ViewScope::Shared); |
| 1409 | // CB-10A: an explicit publication or rename reconciles the mapping first — |
| 1410 | // once a mapping row exists, its local ref is the authoritative projection |
| 1411 | // target (RFC §8.1). Absent mappings keep the pure scope policy. |
| 1412 | if let Ok(Some(mapping)) = repo.get_ref_mapping(view) { |
| 1413 | if let Some(local_ref) = mapping.local_ref.clone() { |
| 1414 | return match scope { |
| 1415 | atomic_core::pristine::ViewScope::Shared => Ok(HeadPolicy::SharedBranch { |
| 1416 | branch_ref: local_ref, |
| 1417 | }), |
| 1418 | atomic_core::pristine::ViewScope::Draft => Ok(HeadPolicy::Draft { |
| 1419 | view_ref: local_ref, |
| 1420 | }), |
| 1421 | }; |
| 1422 | } |
| 1423 | } |
| 1424 | match scope { |
| 1425 | atomic_core::pristine::ViewScope::Shared => Ok(HeadPolicy::SharedBranch { |
| 1426 | branch_ref: format!("refs/heads/{view}"), |
| 1427 | }), |
| 1428 | atomic_core::pristine::ViewScope::Draft => { |
| 1429 | if let Some(original) = ephemeral_original_commit(git_repo, view) { |
| 1430 | Ok(HeadPolicy::Ephemeral { original }) |
| 1431 | } else { |
| 1432 | Ok(HeadPolicy::Draft { |
| 1433 | view_ref: format!("refs/atomic/views/{view}"), |
| 1434 | }) |
| 1435 | } |
| 1436 | } |
| 1437 | } |
| 1438 | } |
| 1439 | |
| 1440 | /// Detect an ephemeral `git/<oid>` view and resolve the commit it adopted. |
| 1441 | /// |
no test coverage detected