`atomic git shim binding resurrect` (CB-6C): exact restoration of a verified binding's closure into a view.
(
id: &str,
remote: Option<String>,
timeout: u64,
insecure: bool,
to_view: Option<String>,
)
| 907 | /// `atomic git shim binding resurrect` (CB-6C): exact restoration of a |
| 908 | /// verified binding's closure into a view. |
| 909 | fn resurrect( |
| 910 | id: &str, |
| 911 | remote: Option<String>, |
| 912 | timeout: u64, |
| 913 | insecure: bool, |
| 914 | to_view: Option<String>, |
| 915 | ) -> CliResult<()> { |
| 916 | use atomic_repository::{ClosureReadiness, IncompletenessReason}; |
| 917 | |
| 918 | let root = find_repository_root()?; |
| 919 | let mut repo = |
| 920 | Repository::open_for_workspace_transaction(&root).map_err(CliError::Repository)?; |
| 921 | let workspace = enter_workspace(&mut repo, boundary_mode(false))?; |
| 922 | |
| 923 | let git = open_git(&root)?; |
| 924 | let binding = resolve_published_binding(&git, id)?; |
| 925 | |
| 926 | // Cryptography + structural verification first: a tampered binding is |
| 927 | // never a source of truth. |
| 928 | verify_binding_cryptography(&binding).map_err(|error| { |
| 929 | CliError::Repository(atomic_repository::RepositoryError::InvalidOperation { |
| 930 | message: format!("binding {} fails cryptography: {error}", binding.id()), |
| 931 | }) |
| 932 | })?; |
| 933 | verify_binding_content(&git, &binding).map_err(|error| { |
| 934 | CliError::Repository(atomic_repository::RepositoryError::InvalidOperation { |
| 935 | message: format!("binding {} does not match Git: {error}", binding.id()), |
| 936 | }) |
| 937 | })?; |
| 938 | |
| 939 | let mut source: Option<HttpBindingChangeSource> = |
| 940 | build_remote_source(&repo, remote.as_deref(), timeout, insecure)?; |
| 941 | let view = match &to_view { |
| 942 | Some(view) => view.clone(), |
| 943 | None => { |
| 944 | let working_copy = repo |
| 945 | .require_working_copy_id() |
| 946 | .map_err(CliError::Repository)?; |
| 947 | repo.desired_view_name(working_copy) |
| 948 | .map_err(CliError::Repository)? |
| 949 | } |
| 950 | }; |
| 951 | |
| 952 | println!( |
| 953 | "Resurrecting binding {} ({} change(s)) into view '{}'", |
| 954 | binding.id().to_hex(), |
| 955 | binding.payload().ordered_changes.len(), |
| 956 | view, |
| 957 | ); |
| 958 | let outcome = match source.as_mut() { |
| 959 | Some(source) => repo |
| 960 | .resurrect_binding_exact(&git, &binding, &view, Some(source)) |
| 961 | .map_err(CliError::Repository)?, |
| 962 | None => repo |
| 963 | .resurrect_binding_exact(&git, &binding, &view, None) |
| 964 | .map_err(CliError::Repository)?, |
| 965 | }; |
| 966 | drop(source); |
no test coverage detected