pub mod receive_pack;
pub mod upload_pack;
use std::path::{Path, PathBuf};
pub fn grit_executable() -> PathBuf {
if let Ok(bin) = std::env::var("GUST_BIN") {
if !bin.is_empty() {
return PathBuf::from(bin);
}
}
if let Ok(exe) = std::env::current_exe() {
let name = exe.file_name().unwrap_or_default().to_string_lossy();
if name.starts_with("grit") {
return exe;
}
}
PathBuf::from("grit")
}
pub fn validate_repo_path(path: &Path) -> anyhow::Result<PathBuf> {
if path.join("HEAD").is_file() {
return Ok(path.to_path_buf());
}
let dot_git = path.join(".git");
if dot_git.join("HEAD").is_file() {
return Ok(path.to_path_buf());
}
anyhow::bail!("not a git repository: {}", path.display())
}