WIP: add github crate
This commit is contained in:
parent
4351fba73a
commit
e51f09ccb3
13 changed files with 130 additions and 62 deletions
|
@ -7,6 +7,7 @@ members = [
|
|||
"crates/git",
|
||||
"crates/forge",
|
||||
"crates/forge-forgejo",
|
||||
"crates/forge-github",
|
||||
"crates/repo-actor",
|
||||
]
|
||||
|
||||
|
@ -26,6 +27,7 @@ git-next-config = { path = "crates/config" }
|
|||
git-next-git = { path = "crates/git" }
|
||||
git-next-forge = { path = "crates/forge" }
|
||||
git-next-forge-forgejo = { path = "crates/forge-forgejo" }
|
||||
git-next-forge-github = { path = "crates/forge-github" }
|
||||
git-next-repo-actor = { path = "crates/repo-actor" }
|
||||
|
||||
# CLI parsing
|
||||
|
|
|
@ -4,7 +4,7 @@ version = { workspace = true }
|
|||
edition = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["forgejo"]
|
||||
default = ["forgejo", "github"]
|
||||
forgejo = []
|
||||
github = []
|
||||
|
||||
|
|
59
crates/forge-github/Cargo.toml
Normal file
59
crates/forge-github/Cargo.toml
Normal file
|
@ -0,0 +1,59 @@
|
|||
[package]
|
||||
name = "git-next-forge-github"
|
||||
version = { workspace = true }
|
||||
edition = { workspace = true }
|
||||
|
||||
[dependencies]
|
||||
git-next-config = { workspace = true }
|
||||
git-next-git = { workspace = true }
|
||||
|
||||
# logging
|
||||
console-subscriber = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
tracing-subscriber = { workspace = true }
|
||||
|
||||
# base64 decoding
|
||||
base64 = { workspace = true }
|
||||
|
||||
# git
|
||||
async-trait = { workspace = true }
|
||||
|
||||
# fs/network
|
||||
kxio = { workspace = true }
|
||||
|
||||
# TOML parsing
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
toml = { workspace = true }
|
||||
|
||||
# Secrets and Password
|
||||
secrecy = { workspace = true }
|
||||
|
||||
# Conventional Commit check
|
||||
git-conventional = { workspace = true }
|
||||
|
||||
# Webhooks
|
||||
bytes = { workspace = true }
|
||||
ulid = { workspace = true }
|
||||
warp = { workspace = true }
|
||||
|
||||
# boilerplate
|
||||
derive_more = { workspace = true }
|
||||
|
||||
# file watcher
|
||||
inotify = { workspace = true }
|
||||
|
||||
# # Actors
|
||||
# actix = { workspace = true }
|
||||
# actix-rt = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
# Testing
|
||||
assert2 = { workspace = true }
|
||||
|
||||
[lints.clippy]
|
||||
nursery = { level = "warn", priority = -1 }
|
||||
# pedantic = "warn"
|
||||
unwrap_used = "warn"
|
||||
expect_used = "warn"
|
39
crates/forge-github/src/lib.rs
Normal file
39
crates/forge-github/src/lib.rs
Normal file
|
@ -0,0 +1,39 @@
|
|||
//
|
||||
#![allow(dead_code)]
|
||||
|
||||
use derive_more::Constructor;
|
||||
use git_next_config as config;
|
||||
use git_next_git as git;
|
||||
|
||||
use kxio::network::Network;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[derive(Clone, Debug, Constructor)]
|
||||
pub struct Github {
|
||||
net: Network,
|
||||
}
|
||||
#[async_trait::async_trait]
|
||||
impl git_next_git::ForgeLike for Github {
|
||||
fn name(&self) -> String {
|
||||
"github".to_string()
|
||||
}
|
||||
async fn branches_get_all(&self) -> Result<Vec<config::BranchName>, git::branch::Error> {
|
||||
todo!();
|
||||
}
|
||||
|
||||
/// Returns the contents of the file.
|
||||
async fn file_contents_get(
|
||||
&self,
|
||||
_branch_name: &config::BranchName,
|
||||
_file_path: &str,
|
||||
) -> Result<String, git::file::Error> {
|
||||
todo!();
|
||||
}
|
||||
|
||||
/// Checks the results of any (e.g. CI) status checks for the commit.
|
||||
async fn commit_status(&self, _commit: &git::Commit) -> git::commit::Status {
|
||||
todo!();
|
||||
}
|
||||
}
|
8
crates/forge-github/src/tests/mod.rs
Normal file
8
crates/forge-github/src/tests/mod.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
use git_next_git::ForgeLike as _;
|
||||
|
||||
#[test]
|
||||
fn test_name() {
|
||||
let net = kxio::network::Network::new_mock();
|
||||
let forge = crate::Github::new(net);
|
||||
assert_eq!(forge.name(), "github");
|
||||
}
|
|
@ -4,14 +4,15 @@ version = { workspace = true }
|
|||
edition = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["forgejo"]
|
||||
default = ["forgejo", "github"]
|
||||
forgejo = ["git-next-forge-forgejo"]
|
||||
github = []
|
||||
github = ["git-next-forge-github"]
|
||||
|
||||
[dependencies]
|
||||
git-next-config = { workspace = true }
|
||||
git-next-git = { workspace = true }
|
||||
git-next-forge-forgejo = { workspace = true, optional = true }
|
||||
git-next-forge-github = { workspace = true, optional = true }
|
||||
|
||||
# logging
|
||||
console-subscriber = { workspace = true }
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
use crate::network::Network;
|
||||
|
||||
struct Github;
|
||||
pub(super) struct GithubEnv {
|
||||
net: Network,
|
||||
}
|
||||
impl GithubEnv {
|
||||
pub(crate) const fn new(net: Network) -> GithubEnv {
|
||||
Self { net }
|
||||
}
|
||||
}
|
||||
#[async_trait::async_trait]
|
||||
impl super::ForgeLike for GithubEnv {
|
||||
fn name(&self) -> String {
|
||||
"github".to_string()
|
||||
}
|
||||
|
||||
async fn branches_get_all(&self) -> Vec<super::Branch> {
|
||||
todo!()
|
||||
}
|
||||
}
|
|
@ -1,34 +1,34 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
//
|
||||
use git_next_forge_forgejo as forgejo;
|
||||
use git_next_forge_github as github;
|
||||
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)]
|
||||
Mock(mock_forge::MockForge),
|
||||
|
||||
#[cfg(feature = "forgejo")]
|
||||
ForgeJo(forgejo::ForgeJo),
|
||||
ForgeJo(git_next_forge_forgejo::ForgeJo),
|
||||
|
||||
#[cfg(feature = "github")]
|
||||
Github(github::GithubEnv),
|
||||
Github(git_next_forge_github::Github),
|
||||
}
|
||||
impl Forge {
|
||||
pub const fn new_mock() -> Self {
|
||||
Self::Mock(mock_forge::MockForgeEnv::new())
|
||||
Self::Mock(mock_forge::MockForge::new())
|
||||
}
|
||||
|
||||
#[cfg(feature = "forgejo")]
|
||||
pub const fn new_forgejo(repo_details: git::RepoDetails, net: Network) -> Self {
|
||||
Self::ForgeJo(forgejo::ForgeJo::new(repo_details, net))
|
||||
}
|
||||
|
||||
#[cfg(feature = "github")]
|
||||
pub const fn new_github(net: Network) -> Self {
|
||||
Self::Github(github::GithubEnv::new(net))
|
||||
Self::Github(github::Github::new(net))
|
||||
}
|
||||
}
|
||||
impl std::ops::Deref for Forge {
|
||||
|
@ -39,7 +39,7 @@ impl std::ops::Deref for Forge {
|
|||
#[cfg(feature = "forgejo")]
|
||||
Self::ForgeJo(env) => env,
|
||||
#[cfg(feature = "github")]
|
||||
Forge::Github(env) => env,
|
||||
Self::Github(env) => env,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
//
|
||||
#![cfg(not(tarpaulin_include))]
|
||||
|
||||
use derive_more::Constructor;
|
||||
use git_next_config as config;
|
||||
use git_next_git as git;
|
||||
|
||||
struct MockForge;
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct MockForgeEnv;
|
||||
impl MockForgeEnv {
|
||||
pub(crate) const fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Debug, Constructor)]
|
||||
pub struct MockForge;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl git::ForgeLike for MockForgeEnv {
|
||||
impl git::ForgeLike for MockForge {
|
||||
fn name(&self) -> String {
|
||||
"mock".to_string()
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_name() {
|
||||
let net = Network::new_mock();
|
||||
let forge = Forge::new_github(net);
|
||||
assert_eq!(forge.name(), "github");
|
||||
}
|
|
@ -4,9 +4,6 @@ use super::*;
|
|||
use git_next_config as config;
|
||||
use git_next_git as git;
|
||||
|
||||
#[cfg(feature = "github")]
|
||||
mod github;
|
||||
|
||||
#[test]
|
||||
fn test_mock_name() {
|
||||
let forge = Forge::new_mock();
|
||||
|
|
|
@ -4,7 +4,7 @@ version = { workspace = true }
|
|||
edition = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["forgejo"]
|
||||
default = ["forgejo", "github"]
|
||||
forgejo = []
|
||||
github = []
|
||||
|
||||
|
|
|
@ -3,11 +3,6 @@ name = "git-next-server"
|
|||
version = { workspace = true }
|
||||
edition = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["forgejo"]
|
||||
forgejo = []
|
||||
github = []
|
||||
|
||||
[dependencies]
|
||||
git-next-config = { workspace = true }
|
||||
git-next-git = { workspace = true }
|
||||
|
|
Loading…
Reference in a new issue