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

Function remediation

atomic-cli/src/commands/git/guard.rs:850–933  ·  view source on GitHub ↗
(
    reason: GuardRefusalReason,
    old: Option<&GuardEvidence>,
    current: &GuardEvidence,
)

Source from the content-addressed store, hash-verified

848}
849
850fn remediation(
851 reason: GuardRefusalReason,
852 old: Option<&GuardEvidence>,
853 current: &GuardEvidence,
854) -> GuardRemediation {
855 let forensic = "atomic status --no-reconcile".to_string();
856 let reconcile = "atomic git shim reconcile".to_string();
857 match reason {
858 GuardRefusalReason::CheckpointMissing | GuardRefusalReason::StaleGitBaseline => {
859 GuardRemediation {
860 summary: "Reconcile the observed Git baseline before retrying the refused operation."
861 .to_string(),
862 commands: vec![forensic, reconcile],
863 }
864 }
865 GuardRefusalReason::Diverged => GuardRemediation {
866 summary: "No automatic authority choice is safe. Inspect both preserved histories, choose the intended side explicitly, and only then reconcile."
867 .to_string(),
868 commands: vec![forensic],
869 },
870 GuardRefusalReason::DetachedHead => {
871 let mut commands = vec![forensic];
872 if let Some(branch) = checkpoint_branch(old) {
873 commands.push(format!("git switch {branch}"));
874 commands.push(reconcile);
875 }
876 GuardRemediation {
877 summary: "Return Git to the checkpoint's attached branch, then reconcile."
878 .to_string(),
879 commands,
880 }
881 }
882 GuardRefusalReason::UnbornHead => GuardRemediation {
883 summary: "Create the repository's initial Git commit, then establish a shim checkpoint."
884 .to_string(),
885 commands: vec![forensic, "git status".to_string(), reconcile],
886 },
887 GuardRefusalReason::MissingHeadTarget => {
888 let mut commands = vec![forensic];
889 if let (Some(branch), Some(oid)) = (checkpoint_branch(old), checkpoint_oid(old)) {
890 commands.push(format!("git branch --force {branch} {oid}"));
891 commands.push(format!("git switch {branch}"));
892 commands.push(reconcile);
893 }
894 GuardRemediation {
895 summary: "Restore the missing branch target from the recorded checkpoint, then reconcile."
896 .to_string(),
897 commands,
898 }
899 }
900 GuardRefusalReason::IndexLocked | GuardRefusalReason::RefLocked => GuardRemediation {
901 summary: "Wait for the active Git process to finish; do not remove a live lock. Re-observe before retrying."
902 .to_string(),
903 commands: vec!["git status".to_string(), forensic],
904 },
905 GuardRefusalReason::GitOperationInProgress => GuardRemediation {
906 summary: format!(
907 "Complete or abort the in-progress Git operation ({}) before reconciliation.",

Callers 1

refuseFunction · 0.85

Calls 3

checkpoint_branchFunction · 0.85
checkpoint_oidFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected