// use git_next_forge_forgejo as forgejo; use git_next_forge_github as github; use git_next_git as git; use kxio::network::Network; mod mock_forge; #[derive(Clone, Debug)] pub enum Forge { Mock(mock_forge::MockForge), #[cfg(feature = "forgejo")] ForgeJo(git_next_forge_forgejo::ForgeJo), #[cfg(feature = "github")] Github(git_next_forge_github::Github), } impl Forge { pub const fn new_mock() -> Self { Self::Mock(mock_forge::MockForge::new()) } #[cfg(feature = "forgejo")] pub const fn new_forgejo(repo_details: git::RepoDetails, net: Network) -> Self { Self::ForgeJo(forgejo::ForgeJo::new(repo_details, net)) } #[cfg(feature = "github")] pub const fn new_github(repo_details: git::RepoDetails, net: Network) -> Self { Self::Github(github::Github::new(repo_details, net)) } } impl std::ops::Deref for Forge { type Target = dyn git::ForgeLike; fn deref(&self) -> &Self::Target { match self { Self::Mock(env) => env, #[cfg(feature = "forgejo")] Self::ForgeJo(env) => env, #[cfg(feature = "github")] Self::Github(env) => env, } } } #[cfg(test)] pub mod tests;