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

Function classify_git_state

atomic-repository/src/repository/workspace_txn.rs:1506–1696  ·  view source on GitHub ↗
(
    mode: WorkspaceTxnMode,
    record: &WorkingCopyRecord,
    view: &ViewState,
    checkpoint: Option<&WorkspaceCheckpoint>,
    observation: &WorkspaceGitObservation,
)

Source from the content-addressed store, hash-verified

1504}
1505
1506fn classify_git_state(
1507 mode: WorkspaceTxnMode,
1508 record: &WorkingCopyRecord,
1509 view: &ViewState,
1510 checkpoint: Option<&WorkspaceCheckpoint>,
1511 observation: &WorkspaceGitObservation,
1512) -> Option<WorkspaceRemediation> {
1513 let WorkspaceGitObservation::Repository(git) = observation else {
1514 return checkpoint.map(|checkpoint| {
1515 unanchored(
1516 mode,
1517 UnanchoredWorkspace::GitRepositoryMissing,
1518 Some(checkpoint),
1519 GitHeadObservation::Unborn {
1520 symref: "no-git".to_string(),
1521 },
1522 )
1523 });
1524 };
1525
1526 let conflict_stages = git.conflict_stages();
1527 if git.operation.is_in_progress() || !conflict_stages.is_empty() {
1528 let disposition = match mode {
1529 WorkspaceTxnMode::Observe => GitOperationDisposition::ObserveOnly,
1530 WorkspaceTxnMode::Reconcile => GitOperationDisposition::FinishOrAbortInGit,
1531 WorkspaceTxnMode::Force => GitOperationDisposition::ForceForbidden,
1532 };
1533 return Some(WorkspaceRemediation::GitOperationInProgress {
1534 mode,
1535 repository_state: git.operation.repository_state.clone(),
1536 markers: git.operation.present_markers(),
1537 conflict_stages,
1538 disposition,
1539 });
1540 }
1541
1542 if git.index_lock.is_present() {
1543 return Some(unanchored(
1544 mode,
1545 UnanchoredWorkspace::IndexLocked {
1546 path: git.index_lock.path.clone(),
1547 },
1548 checkpoint,
1549 git.head.clone(),
1550 ));
1551 }
1552
1553 let observed_oid = match &git.head {
1554 GitHeadObservation::Attached { oid, .. } => oid,
1555 GitHeadObservation::Detached { oid } => {
1556 // CB-7A (RFC §7.5): a detached HEAD is aligned when the checkpoint
1557 // already matches it exactly — recording and observing on an
1558 // ephemeral `git/<oid>` view stay valid. Otherwise it is
1559 // unanchored and the §7.3 adoption may resolve it.
1560 let aligned_detached = match checkpoint {
1561 Some(checkpoint) => {
1562 checkpoint.git_head_symref.is_none()
1563 && checkpoint.git_head == *oid

Callers 1

Calls 11

unanchoredFunction · 0.85
head_symrefFunction · 0.85
conflict_stagesMethod · 0.80
is_noneMethod · 0.80
as_refMethod · 0.80
is_in_progressMethod · 0.45
is_emptyMethod · 0.45
cloneMethod · 0.45
present_markersMethod · 0.45
is_presentMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected