use anyhow::{Result, anyhow};
use std::path::Path;
use std::process::Command;
pub(super) fn run_git_command(repo_path: &Path, args: &[&str]) -> Result<()> {
let output = Command::new("git")
.current_dir(repo_path)
.args(args)
.output()?;
if output.status.success() {
return Ok(());
}
Err(anyhow!(
"Git command failed in {}: {}",
repo_path.display(),
String::from_utf8_lossy(&output.stderr).trim()
))
}
pub(super) fn set_local_config(repo_path: &Path, key: &str, value: Option<&str>) -> Result<()> {
value
.filter(|value| !value.trim().is_empty())
.map_or(Ok(()), |value| {
run_git_command(repo_path, &["config", "--local", key, value])
})
}