32 lines
923 B
Rust
32 lines
923 B
Rust
//
|
|
use git_next_forge_forgejo as forgejo;
|
|
use git_next_forge_github as github;
|
|
use git_next_git as git;
|
|
use kxio::network::Network;
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub enum Forge {
|
|
Mock,
|
|
|
|
#[cfg(feature = "forgejo")]
|
|
ForgeJo(git_next_forge_forgejo::ForgeJo),
|
|
|
|
#[cfg(feature = "github")]
|
|
Github(git_next_forge_github::Github),
|
|
}
|
|
impl Forge {
|
|
pub fn create(repo_details: git::RepoDetails, net: Network) -> Box<dyn git::ForgeLike> {
|
|
match repo_details.forge.forge_type() {
|
|
#[cfg(feature = "forgejo")]
|
|
git_next_config::ForgeType::ForgeJo => {
|
|
Box::new(forgejo::ForgeJo::new(repo_details, net))
|
|
}
|
|
#[cfg(feature = "github")]
|
|
git_next_config::ForgeType::GitHub => Box::new(github::Github::new(repo_details, net)),
|
|
git_next_config::ForgeType::MockForge => unreachable!(),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
pub mod tests;
|