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

Function hook_status

atomic-cli/src/commands/git/hook_dispatchers.rs:265–280  ·  view source on GitHub ↗
(path: &Path)

Source from the content-addressed store, hash-verified

263}
264
265fn 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)]
283mod tests {

Callers 1

dispatcher_statesFunction · 0.85

Calls 5

is_owned_dispatcherFunction · 0.85
git_errorFunction · 0.70
readFunction · 0.50
kindMethod · 0.45
is_fileMethod · 0.45

Tested by

no test coverage detected