refactor: merge github crate into cli crate
All checks were successful
Test / build (map[name:nightly]) (push) Successful in 10m4s
Test / build (map[name:stable]) (push) Successful in 12m12s
Release Please / Release-plz (push) Successful in 1m10s
Release Please / Docker image (push) Successful in 5m56s

This commit is contained in:
Paul Campbell 2025-01-23 13:36:17 +00:00
parent 52de3ef86e
commit c8cc45ca7f
17 changed files with 365 additions and 410 deletions

669
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -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"

View file

@ -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 }

View file

@ -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;

View file

@ -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;

View file

@ -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")]

View file

@ -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}"));
}
}

View file

@ -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

View file

@ -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;

View file

@ -1,5 +1,5 @@
//
use crate as github;
use crate::forges::github;
use git_next_core::{git, webhook};

View file

@ -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;

View file

@ -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

View file

@ -1,3 +1,6 @@
//
#[cfg(feature = "forgejo")]
pub mod forgejo;
#[cfg(feature = "github")]
pub mod github;

View file

@ -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 }

View file

@ -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.