Compare commits

...

7 commits

Author SHA1 Message Date
c8cc45ca7f 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
2025-01-25 20:35:05 +00:00
52de3ef86e refactor: merge forgejo crate into cli crate
All checks were successful
Test / build (map[name:nightly]) (push) Successful in 14m5s
Test / build (map[name:stable]) (push) Successful in 17m12s
Release Please / Release-plz (push) Successful in 1m43s
Release Please / Docker image (push) Successful in 6m22s
2025-01-23 13:36:02 +00:00
f71e28512d build(justfile): run-*-in-docker builds the image first
All checks were successful
Test / build (map[name:nightly]) (push) Successful in 14m3s
Test / build (map[name:stable]) (push) Successful in 19m3s
Release Please / Release-plz (push) Successful in 1m21s
Release Please / Docker image (push) Successful in 5m25s
2025-01-23 13:34:47 +00:00
a605c3499a fix: clippy fixes
All checks were successful
Test / build (map[name:nightly]) (push) Successful in 12m15s
Test / build (map[name:stable]) (push) Successful in 12m37s
Release Please / Release-plz (push) Successful in 1m26s
Release Please / Docker image (push) Successful in 9m26s
2025-01-23 08:35:55 +00:00
030129a746 chore: remove stray file mise.linux.toml
All checks were successful
Test / build (map[name:stable]) (push) Successful in 12m20s
Test / build (map[name:nightly]) (push) Successful in 12m9s
Release Please / Release-plz (push) Successful in 1m6s
Release Please / Docker image (push) Successful in 7m7s
2025-01-20 18:48:01 +00:00
92c24eafd1 fix: include proposed data directory in create error
All checks were successful
Test / build (map[name:nightly]) (push) Successful in 12m5s
Test / build (map[name:stable]) (push) Successful in 15m42s
Release Please / Release-plz (push) Successful in 1m9s
Release Please / Docker image (push) Successful in 5m43s
2025-01-20 10:11:45 +00:00
1694347f00 build: add run{,-ui}-in-docker justfile recipes
All checks were successful
Test / build (map[name:stable]) (push) Successful in 11m14s
Test / build (map[name:nightly]) (push) Successful in 13m17s
Release Please / Release-plz (push) Successful in 49s
Release Please / Docker image (push) Successful in 4m17s
2025-01-20 10:10:05 +00:00
31 changed files with 406 additions and 498 deletions

688
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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

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

View file

@ -11,6 +11,8 @@ mod repo;
mod root;
mod server;
mod forges;
#[cfg(feature = "tui")]
mod tui;

View file

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

View file

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

View file

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

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.

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.

View file

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

View file

@ -1,2 +0,0 @@
[tools]
"cargo:cargo-hack" = "latest"