use crate::error::GitError;
use std::path::PathBuf;
pub fn get_git_hooks_path() -> Result<PathBuf, GitError> {
let output = std::process::Command::new("git")
.arg("rev-parse")
.arg("--git-path")
.arg("hooks")
.output()?;
if !output.status.success() {
return Err(GitError::NotGitRepo);
}
let path = String::from_utf8_lossy(&output.stdout).trim().to_string();
Ok(PathBuf::from(path))
}
#[must_use]
pub fn check_for_git_hooks() -> bool {
let git_hooks = get_git_hooks_path().ok();
git_hooks.is_some_and(|path| path.exists())
}