Remove every Atomic-owned dispatcher `enable_shim` installed, reporting each hook removed or kept.
(root: &Path)
| 44 | /// Remove every Atomic-owned dispatcher `enable_shim` installed, reporting |
| 45 | /// each hook removed or kept. |
| 46 | pub(crate) fn uninstall_shim(root: &Path) -> CliResult<()> { |
| 47 | let root = canonical_root(root)?; |
| 48 | let binary = std::env::current_exe() |
| 49 | .map_err(|error| git_error(format!("cannot resolve the Atomic binary path: {error}")))?; |
| 50 | let context = git_hook_context(&root)?; |
| 51 | if let Some(custom_hooks_path) = context.custom_hooks_path { |
| 52 | print_unmanaged_instructions( |
| 53 | &format!( |
| 54 | "core.hooksPath is configured as '{}'; Atomic did not modify that hook system", |
| 55 | custom_hooks_path.display() |
| 56 | ), |
| 57 | &binary, |
| 58 | )?; |
| 59 | return Ok(()); |
| 60 | } |
| 61 | |
| 62 | let hooks_dir = context.common_dir.join("hooks"); |
| 63 | let dispatchers = ATOMIC_DISPATCHER_HOOKS |
| 64 | .iter() |
| 65 | .map(|hook_name| report_dispatcher_removal(&hooks_dir, hook_name)) |
| 66 | .collect::<CliResult<Vec<bool>>>()?; |
| 67 | let legacy = LEGACY_IMPORT_HOOKS |
| 68 | .iter() |
| 69 | .map(|hook_name| report_legacy_removal(&hooks_dir, hook_name)) |
| 70 | .collect::<CliResult<Vec<bool>>>()?; |
| 71 | if !dispatchers |
| 72 | .iter() |
| 73 | .chain(legacy.iter()) |
| 74 | .any(|removed| *removed) |
| 75 | { |
| 76 | print_info("No Atomic advisory dispatchers are installed."); |
| 77 | } |
| 78 | Ok(()) |
| 79 | } |
| 80 | |
| 81 | /// Remove one advisory dispatcher when Atomic owns it; returns whether a |
| 82 | /// file was removed. |