use derive_more::Constructor;
use crate::{
git::{
self,
repository::{
open::{
otest::{OnFetch, OnPush},
OpenRepository,
},
RepositoryLike, Result,
},
RepoDetails,
},
ForgeDetails, GitDir,
};
#[allow(clippy::module_name_repetitions)]
#[derive(Clone, Debug, Constructor)]
pub struct TestRepository {
fs: kxio::fs::FileSystem,
on_fetch: Vec<git::repository::open::otest::OnFetch>,
on_push: Vec<git::repository::open::otest::OnPush>,
forge_details: ForgeDetails,
}
impl TestRepository {
pub fn on_fetch(&mut self, on_fetch: OnFetch) {
self.on_fetch.push(on_fetch);
}
pub fn on_push(&mut self, on_push: OnPush) {
self.on_push.push(on_push);
}
}
impl RepositoryLike for TestRepository {
fn open(&self, gitdir: &GitDir) -> Result<OpenRepository> {
Ok(git::repository::open::test(
gitdir,
&self.fs,
self.on_fetch.clone(),
self.on_push.clone(),
self.forge_details.clone(),
))
}
fn git_clone(&self, _repo_details: &RepoDetails) -> Result<OpenRepository> {
todo!()
}
}