Menu
AkurAI-Build
publicLatest change 30e6b8c347048d64c2c048dfd05a8ded219d37f6 - Host authenticated Git repositories over Smart HTTP with repo host/sync CLI by Ólafur Búi Ólafsson
use std::{path::Path, process::Command};
use anyhow::{Result, ensure};
pub(crate) fn command(cwd: &Path) -> Command {
let mut command = Command::new("git");
command
.current_dir(cwd)
.env("GIT_TERMINAL_PROMPT", "0")
.env("GIT_CONFIG_NOSYSTEM", "1");
command
}
pub(crate) fn output<const N: usize>(cwd: &Path, arguments: [&str; N]) -> Result<String> {
let output = command(cwd).args(arguments).output()?;
ensure!(
output.status.success(),
"git failed: {}",
String::from_utf8_lossy(&output.stderr)
.chars()
.take(16 * 1024)
.collect::<String>()
.trim()
);
Ok(String::from_utf8_lossy(&output.stdout)
.trim_end()
.to_owned())
}