2024-07-28 13:35:26 +01:00
|
|
|
//
|
|
|
|
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)),
|
2024-09-02 09:14:08 +01:00
|
|
|
_ => {
|
|
|
|
drop(repo_details);
|
|
|
|
drop(net);
|
|
|
|
unreachable!();
|
|
|
|
}
|
2024-07-28 13:35:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
pub mod tests;
|