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;
|
|
|
|
|
|
|
|
mod mock_forge;
|
|
|
|
|
2024-05-04 12:37:35 +01:00
|
|
|
#[derive(Clone, Debug)]
|
2024-04-16 22:21:55 +01:00
|
|
|
pub enum Forge {
|
2024-05-25 11:25:13 +01:00
|
|
|
Mock(mock_forge::MockForge),
|
|
|
|
|
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 {
|
|
|
|
pub const fn new_mock() -> Self {
|
2024-05-25 11:25:13 +01:00
|
|
|
Self::Mock(mock_forge::MockForge::new())
|
2024-04-16 22:21:55 +01:00
|
|
|
}
|
2024-05-25 11:25:13 +01:00
|
|
|
|
2024-04-16 22:21:55 +01:00
|
|
|
#[cfg(feature = "forgejo")]
|
2024-05-26 09:44:56 +01:00
|
|
|
pub const fn new_forgejo(repo_details: git::RepoDetails, net: Network) -> Self {
|
|
|
|
Self::ForgeJo(forgejo::ForgeJo::new(repo_details, net))
|
2024-04-16 22:21:55 +01:00
|
|
|
}
|
2024-05-25 11:25:13 +01:00
|
|
|
|
2024-04-16 22:21:55 +01:00
|
|
|
#[cfg(feature = "github")]
|
2024-05-25 11:25:13 +01:00
|
|
|
pub const fn new_github(repo_details: git::RepoDetails, net: Network) -> Self {
|
|
|
|
Self::Github(github::Github::new(repo_details, net))
|
2024-04-16 22:21:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
impl std::ops::Deref for Forge {
|
2024-05-23 16:50:36 +01:00
|
|
|
type Target = dyn git::ForgeLike;
|
2024-04-16 22:21:55 +01:00
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
match self {
|
|
|
|
Self::Mock(env) => env,
|
|
|
|
#[cfg(feature = "forgejo")]
|
|
|
|
Self::ForgeJo(env) => env,
|
|
|
|
#[cfg(feature = "github")]
|
2024-05-25 11:25:13 +01:00
|
|
|
Self::Github(env) => env,
|
2024-04-16 22:21:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
2024-04-24 07:08:03 +01:00
|
|
|
pub mod tests;
|