git-next/crates/cli/src/forge/mod.rs

36 lines
829 B
Rust
Raw Normal View History

//
use git_next_core::{
git::{ForgeLike, RepoDetails},
ForgeType,
};
#[cfg(feature = "forgejo")]
use git_next_forge_forgejo::ForgeJo;
#[cfg(feature = "github")]
use git_next_forge_github::Github;
use kxio::network::Network;
#[derive(Clone, Debug)]
pub struct Forge;
impl Forge {
pub fn create(repo_details: RepoDetails, net: Network) -> Box<dyn ForgeLike> {
match repo_details.forge.forge_type() {
#[cfg(feature = "forgejo")]
ForgeType::ForgeJo => Box::new(ForgeJo::new(repo_details, net)),
#[cfg(feature = "github")]
ForgeType::GitHub => Box::new(Github::new(repo_details, net)),
_ => {
drop(repo_details);
drop(net);
unreachable!();
}
}
}
}
#[cfg(test)]
pub mod tests;