(
workspace: &Result<Option<PathBuf>, SourceError>,
home: Option<&Path>,
)
| 1308 | } |
| 1309 | |
| 1310 | fn collect_git_shim( |
| 1311 | workspace: &Result<Option<PathBuf>, SourceError>, |
| 1312 | home: Option<&Path>, |
| 1313 | ) -> GitShim { |
| 1314 | let root = match workspace { |
| 1315 | Ok(Some(root)) => root, |
| 1316 | Ok(None) => { |
| 1317 | return GitShim { |
| 1318 | status: ShimStatus::NotApplicable, |
| 1319 | reason: Some("not inside an Atomic workspace".to_string()), |
| 1320 | hooks: GitHooks::NotApplicable, |
| 1321 | } |
| 1322 | } |
| 1323 | Err(reason) => { |
| 1324 | return GitShim { |
| 1325 | status: ShimStatus::Unknown, |
| 1326 | reason: Some(format!("workspace lookup failed: {reason}")), |
| 1327 | hooks: GitHooks::NotApplicable, |
| 1328 | } |
| 1329 | } |
| 1330 | }; |
| 1331 | |
| 1332 | let (status, reason) = match read_shim_config(root) { |
| 1333 | Ok(config) if config.git.shim.enabled => (ShimStatus::Enabled, None), |
| 1334 | Ok(_) => (ShimStatus::Disabled, None), |
| 1335 | Err(reason) => (ShimStatus::Unknown, Some(reason.to_string())), |
| 1336 | }; |
| 1337 | let hooks = match inspect_dispatchers(root) { |
| 1338 | Ok(None) => GitHooks::NoGitRepository, |
| 1339 | Ok(Some(DispatcherReport::External { hooks_path })) => GitHooks::ExternallyManaged { |
| 1340 | hooks_path: display_path(&hooks_path, home), |
| 1341 | }, |
| 1342 | Ok(Some(DispatcherReport::Inspected(hooks))) => GitHooks::Inspected { |
| 1343 | dispatchers: hooks |
| 1344 | .into_iter() |
| 1345 | .map(|hook| Dispatcher { |
| 1346 | hook: hook.name, |
| 1347 | state: hook.state.code(), |
| 1348 | label: hook.state.label(), |
| 1349 | }) |
| 1350 | .collect(), |
| 1351 | }, |
| 1352 | Err(_) => GitHooks::Unreadable { |
| 1353 | reason: "cannot inspect Git repository hooks or administrative paths".to_string(), |
| 1354 | }, |
| 1355 | }; |
| 1356 | GitShim { |
| 1357 | status, |
| 1358 | reason, |
| 1359 | hooks, |
| 1360 | } |
| 1361 | } |
| 1362 | |
| 1363 | /// `path` with the home directory shown as `~`, so a pasted report does not |
| 1364 | /// carry the user's account name. The part after `~` is joined with `/` on |
no test coverage detected