refactor: merge github crate into cli crate
This commit is contained in:
parent
52de3ef86e
commit
c8cc45ca7f
17 changed files with 365 additions and 410 deletions
669
Cargo.lock
generated
669
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -23,7 +23,6 @@ categories = ["development-tools"]
|
|||
|
||||
[workspace.dependencies]
|
||||
git-next-core = { path = "crates/core", version = "0.14" }
|
||||
git-next-forge-github = { path = "crates/forge-github", version = "0.14" }
|
||||
|
||||
# TUI
|
||||
ratatui = "0.29"
|
||||
|
|
|
@ -15,7 +15,7 @@ categories = { workspace = true }
|
|||
# default = ["forgejo", "github"]
|
||||
default = ["forgejo", "github", "tui"]
|
||||
forgejo = []
|
||||
github = ["git-next-forge-github"]
|
||||
github = []
|
||||
tui = [
|
||||
"ratatui",
|
||||
"directories",
|
||||
|
@ -27,7 +27,6 @@ tui = [
|
|||
|
||||
[dependencies]
|
||||
git-next-core = { workspace = true }
|
||||
git-next-forge-github = { workspace = true, optional = true }
|
||||
|
||||
# TUI
|
||||
ratatui = { workspace = true, optional = true }
|
||||
|
@ -89,6 +88,11 @@ notifica = { workspace = true }
|
|||
# git
|
||||
async-trait = { workspace = true }
|
||||
|
||||
# sha256 encoding (e.g. verify github webhooks)
|
||||
hmac = { workspace = true }
|
||||
sha2 = { workspace = true }
|
||||
hex = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
# Testing
|
||||
assert2 = { workspace = true }
|
||||
|
|
|
@ -5,7 +5,7 @@ use git_next_core::git::{ForgeLike, RepoDetails};
|
|||
use crate::forges::forgejo::ForgeJo;
|
||||
|
||||
#[cfg(feature = "github")]
|
||||
use git_next_forge_github::Github;
|
||||
use crate::forges::github::Github;
|
||||
|
||||
use kxio::net::Net;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
use crate::{self as github, GithubState};
|
||||
use crate::forges::github::{self as github, GithubState};
|
||||
use git_next_core::git::{self, forge::commit::Status};
|
||||
use github::GithubStatus;
|
||||
|
|
@ -3,9 +3,9 @@
|
|||
mod tests;
|
||||
|
||||
mod commit;
|
||||
mod webhook;
|
||||
pub mod webhook;
|
||||
|
||||
use crate as github;
|
||||
use crate::forges::github;
|
||||
use git_next_core::{
|
||||
self as core, git,
|
||||
server::{self, RepoListenUrl},
|
||||
|
@ -79,12 +79,12 @@ impl git::ForgeLike for Github {
|
|||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
struct GithubStatus {
|
||||
pub struct GithubStatus {
|
||||
pub state: GithubState,
|
||||
// other fields that we ignore
|
||||
}
|
||||
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||
enum GithubState {
|
||||
pub enum GithubState {
|
||||
#[serde(rename = "success")]
|
||||
Success,
|
||||
#[serde(rename = "pending")]
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
#![allow(clippy::expect_used)]
|
||||
|
||||
use crate::{Github, GithubState, GithubStatus};
|
||||
use crate::forges::github::{Github, GithubState, GithubStatus};
|
||||
use git_next_core::{
|
||||
git::{self, forge::commit::Status, ForgeLike},
|
||||
server::ListenUrl,
|
||||
|
@ -606,7 +606,9 @@ mod github {
|
|||
let mut headers = BTreeMap::new();
|
||||
match header {
|
||||
Header::Valid(auth, body) => {
|
||||
if let Some(sig) = crate::webhook::sign_body(&auth, &body) {
|
||||
if let Some(sig) =
|
||||
crate::forges::github::webhook::authorisation::sign_body(&auth, &body)
|
||||
{
|
||||
headers.insert("x-hub-signature-256".to_string(), format!("sha256={sig}"));
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
use crate as github;
|
||||
use crate::forges::github;
|
||||
use git_next_core::{git, server::RepoListenUrl, WebhookId};
|
||||
|
||||
// https://docs.github.com/en/rest/repos/webhooks?apiVersion=2022-11-28#list-repository-webhooks
|
|
@ -3,7 +3,7 @@ use std::collections::HashMap;
|
|||
//
|
||||
use git_next_core::{git, webhook, ApiToken, BranchName};
|
||||
|
||||
mod authorisation;
|
||||
pub mod authorisation;
|
||||
mod list;
|
||||
mod parser;
|
||||
mod register;
|
||||
|
@ -15,9 +15,6 @@ pub use parser::parse_body;
|
|||
pub use register::register;
|
||||
pub use unregister::unregister;
|
||||
|
||||
#[cfg(test)]
|
||||
pub use authorisation::sign_body;
|
||||
|
||||
pub fn headers(token: &ApiToken) -> HashMap<String, String> {
|
||||
use secrecy::ExposeSecret;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
use crate as github;
|
||||
use crate::forges::github;
|
||||
|
||||
use git_next_core::{git, webhook};
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
use crate::{self as github, webhook};
|
||||
use crate::forges::github::{self as github, webhook};
|
||||
use git_next_core::{git, server::RepoListenUrl, RegisteredWebhook, WebhookAuth, WebhookId};
|
||||
use serde_json::json;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
use crate as github;
|
||||
use crate::forges::github;
|
||||
use git_next_core::{git, WebhookId};
|
||||
|
||||
// https://docs.github.com/en/rest/repos/webhooks?apiVersion=2022-11-28#delete-a-repository-webhook
|
|
@ -1,3 +1,6 @@
|
|||
//
|
||||
#[cfg(feature = "forgejo")]
|
||||
pub mod forgejo;
|
||||
|
||||
#[cfg(feature = "github")]
|
||||
pub mod github;
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
[package]
|
||||
name = "git-next-forge-github"
|
||||
version = { workspace = true }
|
||||
edition = { workspace = true }
|
||||
license = { workspace = true }
|
||||
repository = { workspace = true }
|
||||
description = "GitHub support for git-next, the trunk-based development manager"
|
||||
|
||||
[lints.clippy]
|
||||
nursery = { level = "warn", priority = -1 }
|
||||
pedantic = { level = "warn", priority = -1 }
|
||||
unwrap_used = "warn"
|
||||
expect_used = "warn"
|
||||
|
||||
[lints.rust]
|
||||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }
|
||||
|
||||
[dependencies]
|
||||
git-next-core = { workspace = true }
|
||||
|
||||
# own version for UserAgent requests to github.com
|
||||
clap = { workspace = true }
|
||||
|
||||
# logging
|
||||
tracing = { workspace = true }
|
||||
|
||||
# sha256 encoding (e.g. verify github webhooks)
|
||||
hmac = { workspace = true }
|
||||
sha2 = { workspace = true }
|
||||
hex = { workspace = true }
|
||||
|
||||
# git
|
||||
async-trait = { workspace = true }
|
||||
|
||||
# fs/network
|
||||
kxio = { workspace = true }
|
||||
|
||||
# TOML parsing
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
# Secrets and Password
|
||||
secrecy = { workspace = true }
|
||||
|
||||
# boilerplate
|
||||
derive_more = { workspace = true }
|
||||
|
||||
# # Actors
|
||||
tokio = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
# Testing
|
||||
assert2 = { workspace = true }
|
||||
rand = { workspace = true }
|
|
@ -1,9 +0,0 @@
|
|||
# git-next
|
||||
|
||||
## Trunk-based developement manager.
|
||||
|
||||
`git-next` is a combined server and command-line tool that enables trunk-based
|
||||
development workflows where each commit must pass CI before being included in
|
||||
the main branch.
|
||||
|
||||
See [git-next](https://crates.io/crates/git-next) for more information.
|
Loading…
Add table
Reference in a new issue