use git2::{self, Repository};
use std::path::PathBuf;
use std::fs;
pub struct TestingRepo {
repo: Repository,
}
impl TestingRepo {
pub fn new(name: &str) -> Self {
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
assert!(path.is_dir());
path.push("test");
path.push(name);
fs::remove_dir_all(&path).ok();
let repo = Repository::init_opts(
path,
git2::RepositoryInitOptions::new().bare(true).mkdir(true)
).expect("Could not open/init repository");
TestingRepo { repo: repo }
}
pub fn repo(&mut self) -> &mut Repository {
&mut self.repo
}
}