2024-05-25 11:25:13 +01:00
|
|
|
//
|
2024-05-23 19:36:05 +01:00
|
|
|
use git_next_forge_forgejo as forgejo;
|
2024-05-25 11:25:13 +01:00
|
|
|
use git_next_forge_github as github;
|
2024-05-23 16:19:28 +01:00
|
|
|
use git_next_git as git;
|
2024-04-16 22:21:55 +01:00
|
|
|
use kxio::network::Network;
|
|
|
|
|
2024-05-04 12:37:35 +01:00
|
|
|
#[derive(Clone, Debug)]
|
2024-04-16 22:21:55 +01:00
|
|
|
pub enum Forge {
|
2024-06-19 07:03:08 +01:00
|
|
|
Mock,
|
2024-05-25 11:25:13 +01:00
|
|
|
|
2024-04-16 22:21:55 +01:00
|
|
|
#[cfg(feature = "forgejo")]
|
2024-05-25 11:25:13 +01:00
|
|
|
ForgeJo(git_next_forge_forgejo::ForgeJo),
|
|
|
|
|
2024-04-16 22:21:55 +01:00
|
|
|
#[cfg(feature = "github")]
|
2024-05-25 11:25:13 +01:00
|
|
|
Github(git_next_forge_github::Github),
|
2024-04-16 22:21:55 +01:00
|
|
|
}
|
|
|
|
impl Forge {
|
2024-06-19 07:03:08 +01:00
|
|
|
pub fn create(repo_details: git::RepoDetails, net: Network) -> Box<dyn git::ForgeLike> {
|
2024-06-01 12:03:30 +01:00
|
|
|
match repo_details.forge.forge_type() {
|
|
|
|
#[cfg(feature = "forgejo")]
|
|
|
|
git_next_config::ForgeType::ForgeJo => {
|
2024-06-19 07:03:08 +01:00
|
|
|
Box::new(forgejo::ForgeJo::new(repo_details, net))
|
2024-06-01 12:03:30 +01:00
|
|
|
}
|
|
|
|
#[cfg(feature = "github")]
|
2024-06-19 07:03:08 +01:00
|
|
|
git_next_config::ForgeType::GitHub => Box::new(github::Github::new(repo_details, net)),
|
|
|
|
git_next_config::ForgeType::MockForge => unreachable!(),
|
2024-06-01 12:03:30 +01:00
|
|
|
}
|
2024-04-16 22:21:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
2024-04-24 07:08:03 +01:00
|
|
|
pub mod tests;
|