Compare commits
7 commits
Author | SHA1 | Date | |
---|---|---|---|
c8cc45ca7f | |||
52de3ef86e | |||
f71e28512d | |||
a605c3499a | |||
030129a746 | |||
92c24eafd1 | |||
1694347f00 |
31 changed files with 406 additions and 498 deletions
688
Cargo.lock
generated
688
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -23,8 +23,6 @@ categories = ["development-tools"]
|
|||
|
||||
[workspace.dependencies]
|
||||
git-next-core = { path = "crates/core", version = "0.14" }
|
||||
git-next-forge-forgejo = { path = "crates/forge-forgejo", version = "0.14" }
|
||||
git-next-forge-github = { path = "crates/forge-github", version = "0.14" }
|
||||
|
||||
# TUI
|
||||
ratatui = "0.29"
|
||||
|
|
|
@ -14,8 +14,8 @@ categories = { workspace = true }
|
|||
[features]
|
||||
# default = ["forgejo", "github"]
|
||||
default = ["forgejo", "github", "tui"]
|
||||
forgejo = ["git-next-forge-forgejo"]
|
||||
github = ["git-next-forge-github"]
|
||||
forgejo = []
|
||||
github = []
|
||||
tui = [
|
||||
"ratatui",
|
||||
"directories",
|
||||
|
@ -27,8 +27,6 @@ tui = [
|
|||
|
||||
[dependencies]
|
||||
git-next-core = { workspace = true }
|
||||
git-next-forge-forgejo = { workspace = true, optional = true }
|
||||
git-next-forge-github = { workspace = true, optional = true }
|
||||
|
||||
# TUI
|
||||
ratatui = { workspace = true, optional = true }
|
||||
|
@ -55,6 +53,7 @@ git-conventional = { workspace = true }
|
|||
|
||||
# TOML parsing
|
||||
toml = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
|
||||
# Actors
|
||||
kameo = { workspace = true }
|
||||
|
@ -86,6 +85,14 @@ sendmail = { workspace = true }
|
|||
# desktop notifications
|
||||
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 }
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
use git_next_core::git::{ForgeLike, RepoDetails};
|
||||
|
||||
#[cfg(feature = "forgejo")]
|
||||
use git_next_forge_forgejo::ForgeJo;
|
||||
use crate::forges::forgejo::ForgeJo;
|
||||
|
||||
#[cfg(feature = "github")]
|
||||
use git_next_forge_github::Github;
|
||||
use crate::forges::github::Github;
|
||||
|
||||
use kxio::net::Net;
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
//
|
||||
#![allow(clippy::expect_used)] // used with mock net
|
||||
|
||||
use crate::ForgeJo;
|
||||
use crate::forges::forgejo::ForgeJo;
|
||||
|
||||
use git_next_core::{
|
||||
git::{self, forge::commit::Status, ForgeLike as _},
|
||||
server::{ListenUrl, RepoListenUrl},
|
|
@ -2,7 +2,7 @@
|
|||
use git_next_core::{git, server::RepoListenUrl, WebhookId};
|
||||
use kxio::net::Net;
|
||||
|
||||
use crate::webhook::Hook;
|
||||
use crate::forges::forgejo::webhook::Hook;
|
||||
|
||||
pub async fn list(
|
||||
repo_details: &git::RepoDetails,
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
use crate as forgejo;
|
||||
use crate::forges::forgejo;
|
||||
|
||||
use git_next_core::{git, webhook};
|
||||
|
|
@ -1,14 +1,17 @@
|
|||
use git_next_core::git::forge::webhook::Error;
|
||||
//
|
||||
use git_next_core::{git, server::RepoListenUrl, RegisteredWebhook, WebhookAuth, WebhookId};
|
||||
use git_next_core::{
|
||||
git::{self, forge::webhook::Error},
|
||||
server::RepoListenUrl,
|
||||
RegisteredWebhook, WebhookAuth, WebhookId,
|
||||
};
|
||||
|
||||
use kxio::net::Net;
|
||||
use secrecy::ExposeSecret as _;
|
||||
use serde_json::json;
|
||||
use tracing::{info, instrument, warn};
|
||||
|
||||
use crate::webhook;
|
||||
use crate::webhook::Hook;
|
||||
use crate::forges::forgejo::webhook;
|
||||
use crate::forges::forgejo::webhook::Hook;
|
||||
|
||||
#[instrument(skip_all, fields(forge = %repo_details.forge.forge_alias(), repo = %repo_details.repo_alias))]
|
||||
pub async fn register(
|
|
@ -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
|
6
crates/cli/src/forges/mod.rs
Normal file
6
crates/cli/src/forges/mod.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
//
|
||||
#[cfg(feature = "forgejo")]
|
||||
pub mod forgejo;
|
||||
|
||||
#[cfg(feature = "github")]
|
||||
pub mod github;
|
|
@ -11,6 +11,8 @@ mod repo;
|
|||
mod root;
|
||||
mod server;
|
||||
|
||||
mod forges;
|
||||
|
||||
#[cfg(feature = "tui")]
|
||||
mod tui;
|
||||
|
||||
|
|
|
@ -253,11 +253,11 @@ pub enum RepoState {
|
|||
},
|
||||
}
|
||||
impl RepoState {
|
||||
pub fn repo_alias(&self) -> &RepoAlias {
|
||||
pub const fn repo_alias(&self) -> &RepoAlias {
|
||||
match self {
|
||||
RepoState::Identified { repo_alias, .. }
|
||||
| RepoState::Configured { repo_alias, .. }
|
||||
| RepoState::Ready { repo_alias, .. } => repo_alias,
|
||||
Self::Identified { repo_alias, .. }
|
||||
| Self::Configured { repo_alias, .. }
|
||||
| Self::Ready { repo_alias, .. } => repo_alias,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
use std::path::PathBuf;
|
||||
|
||||
use color_eyre::eyre::Result;
|
||||
use color_eyre::eyre::{Context, Result};
|
||||
use directories::ProjectDirs;
|
||||
use lazy_static::lazy_static;
|
||||
use tracing_error::ErrorLayer;
|
||||
|
@ -30,7 +30,7 @@ fn project_directory() -> Option<ProjectDirs> {
|
|||
}
|
||||
|
||||
pub fn initialize_logging() -> Result<()> {
|
||||
std::fs::create_dir_all(DATA_FOLDER.clone())?;
|
||||
std::fs::create_dir_all(DATA_FOLDER.clone()).context(DATA_FOLDER.display())?;
|
||||
let log_path = DATA_FOLDER.join(LOG_FILE.clone());
|
||||
let log_file = std::fs::File::create(log_path)?;
|
||||
std::env::set_var(
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
[package]
|
||||
name = "git-next-forge-forgejo"
|
||||
version = { workspace = true }
|
||||
edition = { workspace = true }
|
||||
license = { workspace = true }
|
||||
repository = { workspace = true }
|
||||
description = "Forgejo 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 }
|
||||
|
||||
# logging
|
||||
tracing = { 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 }
|
||||
|
||||
# # 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.
|
|
@ -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.
|
11
justfile
11
justfile
|
@ -17,6 +17,17 @@ test-in-docker:
|
|||
shell-in-docker:
|
||||
docker run --rm -u $(id -u):$(id -g) -it -v ${PWD}:/app/ git.kemitix.net/kemitix/rust:latest bash
|
||||
|
||||
docker-test-image := "git.kemitix.net/kemitix/git-next:test"
|
||||
|
||||
build-docker:
|
||||
docker build . -t {{ docker-test-image }}
|
||||
|
||||
run-in-docker: build-docker
|
||||
docker run --rm -u $(id -u):$(id -g) -v ${PWD}:/app/ {{ docker-test-image }} server start
|
||||
|
||||
run-ui-in-docker: build-docker
|
||||
docker run --rm -u $(id -u):$(id -g) -it -v ${PWD}:/app/ {{ docker-test-image }} server start --ui
|
||||
|
||||
install-hooks:
|
||||
@echo "Installing git hooks"
|
||||
cargo install cc-cli
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
[tools]
|
||||
"cargo:cargo-hack" = "latest"
|
Loading…
Add table
Reference in a new issue