use crate::error::MargeError; use git2::Repository; use std::path::PathBuf; fn current_repo() -> Result { let path = std::env::current_dir()?; let repository = git2::Repository::discover(path)?; Ok(repository) } #[allow(dead_code)] pub fn active_branch() -> Result { let name = current_repo()? .head() .unwrap() .shorthand() .unwrap() .to_owned(); Ok(name) } pub fn git_path() -> Result { let path = current_repo()?.path().to_owned(); Ok(path) }