pub mod shell;
pub use shell::{ShellWorktreeInfo as WorktreeInfo, ShellWorktreeManager as WorktreeManager};
pub struct GitUtils;
impl GitUtils {
pub async fn is_git_repo(path: &std::path::Path) -> bool {
path.join(".git").exists()
}
pub async fn get_current_branch(repo_path: &std::path::Path) -> anyhow::Result<String> {
let output = tokio::process::Command::new("git")
.args(["branch", "--show-current"])
.current_dir(repo_path)
.output()
.await?;
if output.status.success() {
Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())
} else {
Err(anyhow::anyhow!("Failed to get current branch"))
}
}
pub async fn get_head_commit(repo_path: &std::path::Path) -> anyhow::Result<String> {
let output = tokio::process::Command::new("git")
.args(["rev-parse", "HEAD"])
.current_dir(repo_path)
.output()
.await?;
if output.status.success() {
Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())
} else {
Err(anyhow::anyhow!("Failed to get HEAD commit"))
}
}
}