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]
|
[workspace.dependencies]
|
||||||
git-next-core = { path = "crates/core", version = "0.14" }
|
git-next-core = { path = "crates/core", version = "0.14" }
|
||||||
git-next-forge-github = { path = "crates/forge-github", version = "0.14" }
|
|
||||||
|
|
||||||
# TUI
|
# TUI
|
||||||
ratatui = "0.29"
|
ratatui = "0.29"
|
||||||
|
|
|
@ -15,7 +15,7 @@ categories = { workspace = true }
|
||||||
# default = ["forgejo", "github"]
|
# default = ["forgejo", "github"]
|
||||||
default = ["forgejo", "github", "tui"]
|
default = ["forgejo", "github", "tui"]
|
||||||
forgejo = []
|
forgejo = []
|
||||||
github = ["git-next-forge-github"]
|
github = []
|
||||||
tui = [
|
tui = [
|
||||||
"ratatui",
|
"ratatui",
|
||||||
"directories",
|
"directories",
|
||||||
|
@ -27,7 +27,6 @@ tui = [
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
git-next-core = { workspace = true }
|
git-next-core = { workspace = true }
|
||||||
git-next-forge-github = { workspace = true, optional = true }
|
|
||||||
|
|
||||||
# TUI
|
# TUI
|
||||||
ratatui = { workspace = true, optional = true }
|
ratatui = { workspace = true, optional = true }
|
||||||
|
@ -89,6 +88,11 @@ notifica = { workspace = true }
|
||||||
# git
|
# git
|
||||||
async-trait = { workspace = true }
|
async-trait = { workspace = true }
|
||||||
|
|
||||||
|
# sha256 encoding (e.g. verify github webhooks)
|
||||||
|
hmac = { workspace = true }
|
||||||
|
sha2 = { workspace = true }
|
||||||
|
hex = { workspace = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
# Testing
|
# Testing
|
||||||
assert2 = { workspace = true }
|
assert2 = { workspace = true }
|
||||||
|
|
|
@ -5,7 +5,7 @@ use git_next_core::git::{ForgeLike, RepoDetails};
|
||||||
use crate::forges::forgejo::ForgeJo;
|
use crate::forges::forgejo::ForgeJo;
|
||||||
|
|
||||||
#[cfg(feature = "github")]
|
#[cfg(feature = "github")]
|
||||||
use git_next_forge_github::Github;
|
use crate::forges::github::Github;
|
||||||
|
|
||||||
use kxio::net::Net;
|
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 git_next_core::git::{self, forge::commit::Status};
|
||||||
use github::GithubStatus;
|
use github::GithubStatus;
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
mod commit;
|
mod commit;
|
||||||
mod webhook;
|
pub mod webhook;
|
||||||
|
|
||||||
use crate as github;
|
use crate::forges::github;
|
||||||
use git_next_core::{
|
use git_next_core::{
|
||||||
self as core, git,
|
self as core, git,
|
||||||
server::{self, RepoListenUrl},
|
server::{self, RepoListenUrl},
|
||||||
|
@ -79,12 +79,12 @@ impl git::ForgeLike for Github {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||||
struct GithubStatus {
|
pub struct GithubStatus {
|
||||||
pub state: GithubState,
|
pub state: GithubState,
|
||||||
// other fields that we ignore
|
// other fields that we ignore
|
||||||
}
|
}
|
||||||
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||||
enum GithubState {
|
pub enum GithubState {
|
||||||
#[serde(rename = "success")]
|
#[serde(rename = "success")]
|
||||||
Success,
|
Success,
|
||||||
#[serde(rename = "pending")]
|
#[serde(rename = "pending")]
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
#![allow(clippy::expect_used)]
|
#![allow(clippy::expect_used)]
|
||||||
|
|
||||||
use crate::{Github, GithubState, GithubStatus};
|
use crate::forges::github::{Github, GithubState, GithubStatus};
|
||||||
use git_next_core::{
|
use git_next_core::{
|
||||||
git::{self, forge::commit::Status, ForgeLike},
|
git::{self, forge::commit::Status, ForgeLike},
|
||||||
server::ListenUrl,
|
server::ListenUrl,
|
||||||
|
@ -606,7 +606,9 @@ mod github {
|
||||||
let mut headers = BTreeMap::new();
|
let mut headers = BTreeMap::new();
|
||||||
match header {
|
match header {
|
||||||
Header::Valid(auth, body) => {
|
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}"));
|
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};
|
use git_next_core::{git, server::RepoListenUrl, WebhookId};
|
||||||
|
|
||||||
// https://docs.github.com/en/rest/repos/webhooks?apiVersion=2022-11-28#list-repository-webhooks
|
// 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};
|
use git_next_core::{git, webhook, ApiToken, BranchName};
|
||||||
|
|
||||||
mod authorisation;
|
pub mod authorisation;
|
||||||
mod list;
|
mod list;
|
||||||
mod parser;
|
mod parser;
|
||||||
mod register;
|
mod register;
|
||||||
|
@ -15,9 +15,6 @@ pub use parser::parse_body;
|
||||||
pub use register::register;
|
pub use register::register;
|
||||||
pub use unregister::unregister;
|
pub use unregister::unregister;
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
pub use authorisation::sign_body;
|
|
||||||
|
|
||||||
pub fn headers(token: &ApiToken) -> HashMap<String, String> {
|
pub fn headers(token: &ApiToken) -> HashMap<String, String> {
|
||||||
use secrecy::ExposeSecret;
|
use secrecy::ExposeSecret;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
use crate as github;
|
use crate::forges::github;
|
||||||
|
|
||||||
use git_next_core::{git, webhook};
|
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 git_next_core::{git, server::RepoListenUrl, RegisteredWebhook, WebhookAuth, WebhookId};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
use crate as github;
|
use crate::forges::github;
|
||||||
use git_next_core::{git, WebhookId};
|
use git_next_core::{git, WebhookId};
|
||||||
|
|
||||||
// https://docs.github.com/en/rest/repos/webhooks?apiVersion=2022-11-28#delete-a-repository-webhook
|
// https://docs.github.com/en/rest/repos/webhooks?apiVersion=2022-11-28#delete-a-repository-webhook
|
|
@ -1,3 +1,6 @@
|
||||||
//
|
//
|
||||||
#[cfg(feature = "forgejo")]
|
#[cfg(feature = "forgejo")]
|
||||||
pub mod 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