forked from kemitix/git-next
52 lines
1.3 KiB
Rust
52 lines
1.3 KiB
Rust
#![allow(dead_code)]
|
|
|
|
use git_next_forge_forgejo as forgejo;
|
|
use git_next_git as git;
|
|
use kxio::network::Network;
|
|
|
|
#[cfg(feature = "github")]
|
|
mod github;
|
|
|
|
mod mock_forge;
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub enum Forge {
|
|
Mock(mock_forge::MockForgeEnv),
|
|
#[allow(clippy::enum_variant_names)]
|
|
#[cfg(feature = "forgejo")]
|
|
ForgeJo(forgejo::ForgeJo),
|
|
#[cfg(feature = "github")]
|
|
Github(github::GithubEnv),
|
|
}
|
|
impl Forge {
|
|
pub const fn new_mock() -> Self {
|
|
Self::Mock(mock_forge::MockForgeEnv::new())
|
|
}
|
|
#[cfg(feature = "forgejo")]
|
|
pub const fn new_forgejo(
|
|
repo_details: git::RepoDetails,
|
|
net: Network,
|
|
repo: git::Repository,
|
|
) -> Self {
|
|
Self::ForgeJo(forgejo::ForgeJo::new(repo_details, net, repo))
|
|
}
|
|
#[cfg(feature = "github")]
|
|
pub const fn new_github(net: Network) -> Self {
|
|
Self::Github(github::GithubEnv::new(net))
|
|
}
|
|
}
|
|
impl std::ops::Deref for Forge {
|
|
type Target = dyn git::ForgeLike;
|
|
fn deref(&self) -> &Self::Target {
|
|
match self {
|
|
Self::Mock(env) => env,
|
|
#[cfg(feature = "forgejo")]
|
|
Self::ForgeJo(env) => env,
|
|
#[cfg(feature = "github")]
|
|
Forge::Github(env) => env,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
pub mod tests;
|