pub fn git_sh() -> Option<std::path::PathBuf> {
let exe_name = if cfg!(target_os = "windows") {
"bash.exe"
} else {
"sh"
};
if cfg!(target_os = "windows") {
if let Some(path) = find_git_bash() {
return Some(path);
}
}
which::which(exe_name).ok()
}
fn find_git_bash() -> Option<std::path::PathBuf> {
let git_path = which::which("git.exe").ok()?;
let git_dir = git_path.parent()?.parent()?;
let git_bash = git_dir.join("bin").join("bash.exe");
git_bash.is_file().then_some(git_bash)
}