(path: &Path)
| 263 | } |
| 264 | |
| 265 | fn hook_status(path: &Path) -> CliResult<HookState> { |
| 266 | match fs::symlink_metadata(path) { |
| 267 | Err(error) if error.kind() == ErrorKind::NotFound => Ok(HookState::NotInstalled), |
| 268 | Err(error) => Err(git_error(format!( |
| 269 | "cannot inspect hook '{}': {error}", |
| 270 | path.display() |
| 271 | ))), |
| 272 | Ok(metadata) if metadata.file_type().is_symlink() => Ok(HookState::UnmanagedSymlink), |
| 273 | Ok(metadata) if !metadata.file_type().is_file() => Ok(HookState::UnmanagedNonFile), |
| 274 | Ok(_) => Ok(match fs::read(path) { |
| 275 | Ok(content) if is_owned_dispatcher(&content) => HookState::AtomicOwned, |
| 276 | Ok(_) => HookState::Unmanaged, |
| 277 | Err(_) => HookState::UnmanagedUnreadable, |
| 278 | }), |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | #[cfg(test)] |
| 283 | mod tests { |
no test coverage detected