#![cfg(test)]
use std::path::Path;
use std::process::Command;
pub(crate) fn git(cwd: &Path, args: &[&str]) {
let status = Command::new("git")
.args(args)
.current_dir(cwd)
.status()
.expect("git available on $PATH");
assert!(status.success(), "git {args:?} failed in {}", cwd.display());
}
pub(crate) fn init_repo(cwd: &Path) {
git(cwd, &["init", "-q"]);
git(cwd, &["config", "commit.gpgsign", "false"]);
}
pub(crate) fn commit(cwd: &Path, file: &str, body: &str, email: &str, msg: &str) {
std::fs::write(cwd.join(file), body).unwrap();
git(cwd, &["add", file]);
git(
cwd,
&[
"-c",
&format!("user.email={email}"),
"-c",
"user.name=tester",
"commit",
"-q",
"-m",
msg,
],
);
}