refactor: merge git create into core crate
Some checks failed
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
Rust / build (push) Has been cancelled
ci/woodpecker/push/tag-created Pipeline was successful

This commit is contained in:
Paul Campbell 2024-07-26 06:49:09 +01:00
parent b8f4adeb50
commit fa5fa809d9
90 changed files with 357 additions and 391 deletions

View file

@ -523,32 +523,22 @@ stateDiagram-v2
cli --> server cli --> server
cli --> git
forge --> core forge --> core
forge --> git
forge --> forge_forgejo forge --> forge_forgejo
forge --> forge_github forge --> forge_github
forge_forgejo --> core forge_forgejo --> core
forge_forgejo --> git
forge_github --> core forge_github --> core
forge_github --> git
git --> core
repo_actor --> core repo_actor --> core
repo_actor --> git
repo_actor --> forge repo_actor --> forge
server --> core server --> core
server --> git
server --> file_watcher_actor server --> file_watcher_actor
server --> server_actor server --> server_actor
server_actor --> core server_actor --> core
server_actor --> git
server_actor --> forge server_actor --> forge
server_actor --> repo_actor server_actor --> repo_actor
server_actor --> file_watcher_actor server_actor --> file_watcher_actor

View file

@ -4,6 +4,8 @@ mod init;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
use git_next_core::git;
use std::path::PathBuf; use std::path::PathBuf;
use clap::Parser; use clap::Parser;
@ -30,7 +32,7 @@ enum Server {
fn main() { fn main() {
let fs = fs::new(PathBuf::default()); let fs = fs::new(PathBuf::default());
let net = Network::new_real(); let net = Network::new_real();
let repository_factory = git_next_git::repository::factory::real(); let repository_factory = git::repository::factory::real();
let commands = Commands::parse(); let commands = Commands::parse();
match commands.command { match commands.command {

View file

@ -34,6 +34,7 @@ secrecy = { workspace = true }
# Git # Git
gix = { workspace = true } gix = { workspace = true }
git-url-parse = { workspace = true } git-url-parse = { workspace = true }
async-trait = { workspace = true }
# Webhooks # Webhooks
ulid = { workspace = true } ulid = { workspace = true }
@ -44,11 +45,17 @@ derive-with = { workspace = true }
thiserror = { workspace = true } thiserror = { workspace = true }
pike = { workspace = true } pike = { workspace = true }
# TOML parsing
serde_json = { workspace = true }
mockall = { workspace = true }
[dev-dependencies] [dev-dependencies]
# Testing # Testing
assert2 = { workspace = true } assert2 = { workspace = true }
rand = { workspace = true } rand = { workspace = true }
test-log = { workspace = true } test-log = { workspace = true }
pretty_assertions = { workspace = true }
[lints.clippy] [lints.clippy]
nursery = { level = "warn", priority = -1 } nursery = { level = "warn", priority = -1 }

View file

@ -1,5 +1,5 @@
// //
use git_next_core::{newtype, webhook}; use crate::{newtype, webhook};
use derive_more::Display; use derive_more::Display;
use serde::Serialize; use serde::Serialize;
@ -50,7 +50,7 @@ pub struct Histories {
} }
pub mod log { pub mod log {
use git_next_core::BranchName; use crate::BranchName;
pub type Result<T> = core::result::Result<T, Error>; pub type Result<T> = core::result::Result<T, Error>;

View file

@ -28,7 +28,7 @@ pub enum Error {
Unknown(String), Unknown(String),
#[error("commit log: {0}")] #[error("commit log: {0}")]
CommitLog(#[from] crate::commit::log::Error), CommitLog(#[from] crate::git::commit::log::Error),
#[error("commit not found")] #[error("commit not found")]
CommitNotFound, CommitNotFound,

View file

@ -1,8 +1,6 @@
// //
use crate as git; use crate::{
git, server::WebhookUrl, webhook, ForgeNotification, RegisteredWebhook, WebhookAuth, WebhookId,
use git_next_core::{
server::WebhookUrl, webhook, ForgeNotification, RegisteredWebhook, WebhookAuth, WebhookId,
}; };
#[mockall::automock] #[mockall::automock]

View file

@ -1,5 +1,6 @@
use derive_more::Display; use derive_more::Display;
use git_next_core::newtype;
use crate::newtype;
newtype!(Generation: u32, Display, Default, Copy: r#"A counter for the server generation. newtype!(Generation: u32, Display, Default, Copy: r#"A counter for the server generation.

View file

@ -1,9 +1,9 @@
// //
use git_next_core::newtype; use crate::newtype;
use derive_more::Display; use derive_more::Display;
use crate::{commit::Sha, Commit}; use crate::git::{commit::Sha, Commit};
newtype!(GitRef: String, Display: "A git reference to a git commit."); newtype!(GitRef: String, Display: "A git reference to a git commit.");
impl From<Commit> for GitRef { impl From<Commit> for GitRef {

View file

@ -1,7 +1,7 @@
// //
use derive_more::{Constructor, Display}; use derive_more::{Constructor, Display};
use git_next_core::{Hostname, RepoPath}; use crate::{Hostname, RepoPath};
#[derive(Clone, Debug, PartialEq, Eq, Constructor, Display)] #[derive(Clone, Debug, PartialEq, Eq, Constructor, Display)]
#[display("{}:{}", host, repo_path)] #[display("{}:{}", host, repo_path)]

View file

@ -0,0 +1,52 @@
//
pub mod commit;
pub mod fetch;
pub mod file;
pub mod forge;
mod generation;
mod git_ref;
mod git_remote;
pub mod push;
mod repo_details;
pub mod repository;
mod user_notification;
pub mod validation;
#[cfg(test)]
mod tests;
pub use commit::Commit;
pub use forge::like::ForgeLike;
pub use forge::like::MockForgeLike;
pub use generation::Generation;
pub use git_ref::GitRef;
pub use git_remote::GitRemote;
pub use repo_details::RepoDetails;
pub use repository::Repository;
pub use repository::RepositoryFactory;
pub use user_notification::UserNotification;
use crate::common::branch_name;
use crate::common::repo_alias;
use crate::common::repo_path;
use crate::ForgeDetails;
use crate::GitDir;
use crate::RepoConfig;
pub fn repo_details(
n: u32,
generation: Generation,
forge: ForgeDetails,
repo_config: Option<RepoConfig>,
gitdir: GitDir,
) -> RepoDetails {
RepoDetails {
generation,
repo_alias: repo_alias(n),
repo_path: repo_path(n),
gitdir,
branch: branch_name(n),
forge,
repo_config,
}
}

View file

@ -1,6 +1,5 @@
// //
use crate::{self as git, repository::open::OpenRepositoryLike}; use crate::{git, git::repository::open::OpenRepositoryLike, BranchName};
use git_next_core::BranchName;
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub enum Force { pub enum Force {

View file

@ -1,9 +1,10 @@
// //
use crate::{ use crate::{
repository::open::{oreal::RealOpenRepository, OpenRepositoryLike}, git::{
Generation, GitRemote, self,
}; repository::open::{oreal::RealOpenRepository, OpenRepositoryLike},
use git_next_core::{ Generation, GitRemote,
},
pike, BranchName, ForgeAlias, ForgeConfig, ForgeDetails, GitDir, Hostname, RemoteUrl, pike, BranchName, ForgeAlias, ForgeConfig, ForgeDetails, GitDir, Hostname, RemoteUrl,
RepoAlias, RepoConfig, RepoPath, ServerRepoConfig, StoragePathType, RepoAlias, RepoConfig, RepoPath, ServerRepoConfig, StoragePathType,
}; };
@ -86,7 +87,7 @@ impl RepoDetails {
} }
#[allow(clippy::result_large_err)] #[allow(clippy::result_large_err)]
pub fn open(&self) -> Result<impl OpenRepositoryLike, crate::validation::remotes::Error> { pub fn open(&self) -> Result<impl OpenRepositoryLike, git::validation::remotes::Error> {
let gix_repo = pike! { let gix_repo = pike! {
self self
|> Self::gitdir |> Self::gitdir
@ -108,7 +109,7 @@ impl RepoDetails {
} }
#[tracing::instrument] #[tracing::instrument]
pub fn assert_remote_url(&self, found: Option<RemoteUrl>) -> crate::repository::Result<()> { pub fn assert_remote_url(&self, found: Option<RemoteUrl>) -> git::repository::Result<()> {
let Some(found) = found else { let Some(found) = found else {
tracing::debug!("No remote url found to assert"); tracing::debug!("No remote url found to assert");
return Ok(()); return Ok(());
@ -122,7 +123,7 @@ impl RepoDetails {
match self.gitdir.storage_path_type() { match self.gitdir.storage_path_type() {
StoragePathType::External => { StoragePathType::External => {
tracing::debug!("Refusing to update an external repo - user must resolve this"); tracing::debug!("Refusing to update an external repo - user must resolve this");
return Err(crate::repository::Error::MismatchDefaultFetchRemote { return Err(git::repository::Error::MismatchDefaultFetchRemote {
found: Box::new(found), found: Box::new(found),
expected: Box::new(expected), expected: Box::new(expected),
}); });

View file

@ -1,5 +1,6 @@
// //
use crate::{ use crate::git::{
self,
repository::{ repository::{
open::{oreal::RealOpenRepository, OpenRepositoryLike}, open::{oreal::RealOpenRepository, OpenRepositoryLike},
Direction, Result, Direction, Result,
@ -34,7 +35,7 @@ impl RepositoryFactory for RealRepositoryFactory {
fn open(&self, repo_details: &RepoDetails) -> Result<Box<dyn OpenRepositoryLike>> { fn open(&self, repo_details: &RepoDetails) -> Result<Box<dyn OpenRepositoryLike>> {
let repo = repo_details let repo = repo_details
.open() .open()
.map_err(|e| crate::repository::Error::Open(e.to_string()))?; .map_err(|e| git::repository::Error::Open(e.to_string()))?;
let found = repo.find_default_remote(Direction::Fetch); let found = repo.find_default_remote(Direction::Fetch);
repo_details.assert_remote_url(found)?; repo_details.assert_remote_url(found)?;

View file

@ -1,13 +1,15 @@
// //
use crate::{ use crate::{
repository::{ git::{
open::{OpenRepository, OpenRepositoryLike}, repository::{
test::TestRepository, open::{OpenRepository, OpenRepositoryLike},
test::TestRepository,
},
validation::remotes::validate_default_remotes,
RepoDetails,
}, },
validation::remotes::validate_default_remotes, GitDir, RemoteUrl,
RepoDetails,
}; };
use git_next_core::{GitDir, RemoteUrl};
use tracing::info; use tracing::info;

View file

@ -5,12 +5,14 @@ mod tests;
pub mod oreal; pub mod oreal;
pub mod otest; pub mod otest;
use crate as git; use crate::{
use git::repository::{ git,
open::{oreal::RealOpenRepository, otest::TestOpenRepository}, git::repository::{
Direction, open::{oreal::RealOpenRepository, otest::TestOpenRepository},
Direction,
},
BranchName, GitDir, RemoteUrl,
}; };
use git_next_core::{BranchName, GitDir, RemoteUrl};
use std::{ use std::{
path::Path, path::Path,

View file

@ -1,7 +1,8 @@
// //
use crate::{self as git, repository::OpenRepositoryLike}; use crate::{
git::{self, repository::OpenRepositoryLike},
use git_next_core::{BranchName, Hostname, RemoteUrl, RepoPath}; BranchName, Hostname, RemoteUrl, RepoPath,
};
use derive_more::Constructor; use derive_more::Constructor;
use gix::bstr::BStr; use gix::bstr::BStr;
@ -129,7 +130,7 @@ impl super::OpenRepositoryLike for RealOpenRepository {
&self, &self,
branch_name: &BranchName, branch_name: &BranchName,
find_commits: &[git::Commit], find_commits: &[git::Commit],
) -> Result<Vec<crate::Commit>, git::commit::log::Error> { ) -> Result<Vec<git::Commit>, git::commit::log::Error> {
let limit = match find_commits.is_empty() { let limit = match find_commits.is_empty() {
true => 1, true => 1,
false => 50, false => 50,

View file

@ -1,11 +1,12 @@
// //
use crate::{ use crate::{
self as git, git::{
repository::open::{OpenRepositoryLike, RealOpenRepository}, self,
repository::open::{OpenRepositoryLike, RealOpenRepository},
},
BranchName, GitDir, RemoteUrl, RepoBranches,
}; };
use git_next_core::{BranchName, GitDir, RemoteUrl, RepoBranches};
use derive_more::{Constructor, Deref}; use derive_more::{Constructor, Deref};
use std::{ use std::{
@ -126,7 +127,7 @@ impl git::repository::OpenRepositoryLike for TestOpenRepository {
&self, &self,
branch_name: &BranchName, branch_name: &BranchName,
find_commits: &[git::Commit], find_commits: &[git::Commit],
) -> git::commit::log::Result<Vec<crate::Commit>> { ) -> git::commit::log::Result<Vec<git::Commit>> {
self.real.commit_log(branch_name, find_commits) self.real.commit_log(branch_name, find_commits)
} }

View file

@ -8,6 +8,6 @@ fn should_fetch_from_repo() {
let_assert!(Ok(cwd) = std::env::current_dir()); let_assert!(Ok(cwd) = std::env::current_dir());
let gitdir = GitDir::new(cwd.join("../.."), StoragePathType::External); let gitdir = GitDir::new(cwd.join("../.."), StoragePathType::External);
let repo_details = given::repo_details(&given::a_filesystem()).with_gitdir(gitdir); let repo_details = given::repo_details(&given::a_filesystem()).with_gitdir(gitdir);
let_assert!(Ok(repo) = crate::repository::factory::real().open(&repo_details)); let_assert!(Ok(repo) = crate::git::repository::factory::real().open(&repo_details));
let_assert!(Ok(_) = repo.fetch()); let_assert!(Ok(_) = repo.fetch());
} }

View file

@ -9,6 +9,6 @@ fn should_find_default_push_remote() {
let url = repo_details.url(); let url = repo_details.url();
given::a_bare_repo_with_url(fs.base(), url.expose_secret(), &fs); given::a_bare_repo_with_url(fs.base(), url.expose_secret(), &fs);
let_assert!(Ok(repo) = git::repository::factory::real().open(&repo_details)); let_assert!(Ok(repo) = git::repository::factory::real().open(&repo_details));
let remote = repo.find_default_remote(crate::repository::Direction::Push); let remote = repo.find_default_remote(git::repository::Direction::Push);
assert!(remote.is_some()); assert!(remote.is_some());
} }

View file

@ -1,10 +1,10 @@
// //
use crate::{ use crate::{
self as git, git::{
repository::RepositoryLike as _, self,
tests::{given, then}, repository::RepositoryLike as _,
}; tests::{given, then},
use git_next_core::{ },
BranchName, ForgeConfig, ForgeType, GitDir, Hostname, RepoAlias, RepoBranches, RepoConfig, BranchName, ForgeConfig, ForgeType, GitDir, Hostname, RepoAlias, RepoBranches, RepoConfig,
RepoConfigSource, RepoPath, ServerRepoConfig, StoragePathType, User, RepoConfigSource, RepoPath, ServerRepoConfig, StoragePathType, User,
}; };

View file

@ -2,17 +2,19 @@
use derive_more::Constructor; use derive_more::Constructor;
use crate::{ use crate::{
self as git, git::{
repository::{ self,
open::{ repository::{
otest::{OnFetch, OnPush}, open::{
OpenRepository, otest::{OnFetch, OnPush},
OpenRepository,
},
RepositoryLike, Result,
}, },
RepositoryLike, Result, RepoDetails,
}, },
RepoDetails, GitDir,
}; };
use git_next_core::GitDir;
#[derive(Clone, Debug, Constructor)] #[derive(Clone, Debug, Constructor)]
pub struct TestRepository { pub struct TestRepository {

View file

@ -15,7 +15,7 @@ fn open_where_storage_external_auth_matches() -> TestResult {
let url = repo_details.url(); let url = repo_details.url();
let url = url.expose_secret(); let url = url.expose_secret();
given::a_bare_repo_with_url(fs.base(), url, &fs); given::a_bare_repo_with_url(fs.base(), url, &fs);
let factory = crate::repository::factory::real(); let factory = git::repository::factory::real();
//when //when
let result = factory.open(&repo_details); let result = factory.open(&repo_details);
@ -42,7 +42,7 @@ fn open_where_storage_external_auth_differs_error() -> TestResult {
let original_url = original_url.expose_secret(); let original_url = original_url.expose_secret();
given::a_bare_repo_with_url(fs.base(), original_url, &fs); given::a_bare_repo_with_url(fs.base(), original_url, &fs);
let gitdir = GitDir::new(fs.base().to_path_buf(), StoragePathType::External); let gitdir = GitDir::new(fs.base().to_path_buf(), StoragePathType::External);
let factory = crate::repository::factory::real(); let factory = git::repository::factory::real();
// create new authentication // create new authentication
let api_token = ApiToken::new(given::a_name().into()); let api_token = ApiToken::new(given::a_name().into());
let forge_details = repo_details.forge.clone().with_token(api_token); let forge_details = repo_details.forge.clone().with_token(api_token);
@ -80,7 +80,7 @@ fn open_where_storage_internal_auth_matches() -> TestResult {
let url = url.expose_secret(); let url = url.expose_secret();
// create a bare repg with the auth from the forge_config // create a bare repg with the auth from the forge_config
given::a_bare_repo_with_url(fs.base(), url, &fs); given::a_bare_repo_with_url(fs.base(), url, &fs);
let factory = crate::repository::factory::real(); let factory = git::repository::factory::real();
//when //when
let result = factory.open(&repo_details); let result = factory.open(&repo_details);
@ -110,7 +110,7 @@ fn open_where_storage_internal_auth_differs_update_config() -> TestResult {
let original_url = original_url.expose_secret(); let original_url = original_url.expose_secret();
given::a_bare_repo_with_url(fs.base(), original_url, &fs); given::a_bare_repo_with_url(fs.base(), original_url, &fs);
let gitdir = GitDir::new(fs.base().to_path_buf(), StoragePathType::Internal); let gitdir = GitDir::new(fs.base().to_path_buf(), StoragePathType::Internal);
let factory = crate::repository::factory::real(); let factory = git::repository::factory::real();
// create new authentication // create new authentication
let api_token = ApiToken::new(given::a_name().into()); let api_token = ApiToken::new(given::a_name().into());
let forge_details = repo_details.forge.clone().with_token(api_token); let forge_details = repo_details.forge.clone().with_token(api_token);

View file

@ -1,6 +1,8 @@
// //
use crate::{self as git, tests::given}; use crate::{
use git_next_core::{ApiToken, GitDir, StoragePathType}; git::{self, tests::given},
ApiToken, GitDir, StoragePathType,
};
use assert2::let_assert; use assert2::let_assert;

View file

@ -1,9 +1,9 @@
// //
use crate::{self as git, Generation, GitRef, GitRemote, RepoDetails}; use crate::{
use git_next_core::{ git::{self, Generation, GitRef, GitRemote, RepoDetails},
git_dir::StoragePathType, webhook, BranchName, ForgeAlias, ForgeConfig, ForgeType, GitDir, git_dir::StoragePathType,
Hostname, RemoteUrl, RepoAlias, RepoBranches, RepoConfig, RepoConfigSource, RepoPath, webhook, BranchName, ForgeAlias, ForgeConfig, ForgeType, GitDir, Hostname, RemoteUrl,
ServerRepoConfig, RepoAlias, RepoBranches, RepoConfig, RepoConfigSource, RepoPath, ServerRepoConfig,
}; };
use assert2::let_assert; use assert2::let_assert;

View file

@ -1,7 +1,5 @@
// //
use crate::Commit; use crate::{git::Commit, BranchName, ForgeAlias, RepoAlias};
use git_next_core::{BranchName, ForgeAlias, RepoAlias};
#[derive(Clone, Debug, PartialEq, Eq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub enum UserNotification { pub enum UserNotification {

View file

@ -1,6 +1,8 @@
// //
use crate::{self as git, repository::open::OpenRepositoryLike, RepoDetails, UserNotification}; use crate::{
use git_next_core::{BranchName, RepoConfig}; git::{self, repository::open::OpenRepositoryLike, RepoDetails, UserNotification},
BranchName, RepoConfig,
};
pub type Result<T> = core::result::Result<T, Error>; pub type Result<T> = core::result::Result<T, Error>;
@ -100,7 +102,7 @@ fn reset_next_to_main(
))) )))
} }
fn is_not_based_on(commits: &[crate::commit::Commit], needle: &crate::Commit) -> bool { fn is_not_based_on(commits: &[git::commit::Commit], needle: &git::Commit) -> bool {
commits.iter().filter(|commit| *commit == needle).count() == 0 commits.iter().filter(|commit| *commit == needle).count() == 0
} }

View file

@ -1,6 +1,8 @@
// //
use crate::{self as git, repository::open::OpenRepositoryLike}; use crate::{
use git_next_core::RemoteUrl; git::{self, repository::open::OpenRepositoryLike},
RemoteUrl,
};
use tracing::info; use tracing::info;

View file

@ -1,18 +1,17 @@
// //
use crate::{ use crate::{
self as git, git::{
repository::{ self,
open::otest::{OnFetch, OnPush}, repository::{
Direction, factory::RepositoryFactory as _,
open::otest::{OnFetch, OnPush},
Direction, RepositoryLike as _,
},
tests::{given, then},
validation::positions::validate_positions,
}, },
tests::then, GitDir, StoragePathType,
}; };
use git::{
repository::{factory::RepositoryFactory as _, RepositoryLike as _},
tests::given,
validation::positions::validate_positions,
};
use git_next_core::{GitDir, StoragePathType};
use assert2::let_assert; use assert2::let_assert;

View file

@ -1,4 +1,5 @@
mod config; mod config;
pub mod git;
mod macros; mod macros;
pub use config::*; pub use config::*;

View file

@ -4,11 +4,10 @@ mod tests;
mod webhook; mod webhook;
use git::forge::commit::Status;
use git_next_core::{ use git_next_core::{
self as core, server, ForgeNotification, RegisteredWebhook, WebhookAuth, WebhookId, self as core, git, git::forge::commit::Status, server, ForgeNotification, RegisteredWebhook,
WebhookAuth, WebhookId,
}; };
use git_next_git as git;
use kxio::network::{self, Network}; use kxio::network::{self, Network};
use tracing::warn; use tracing::warn;

View file

@ -1,11 +1,11 @@
// //
use crate::ForgeJo; use crate::ForgeJo;
use git_next_core::{ use git_next_core::{
git::{self, forge::commit::Status, ForgeLike as _},
server::{InboundWebhook, WebhookUrl}, server::{InboundWebhook, WebhookUrl},
BranchName, ForgeAlias, ForgeConfig, ForgeNotification, ForgeType, GitDir, Hostname, RepoAlias, BranchName, ForgeAlias, ForgeConfig, ForgeNotification, ForgeType, GitDir, Hostname, RepoAlias,
RepoBranches, RepoPath, ServerRepoConfig, StoragePathType, WebhookAuth, WebhookId, RepoBranches, RepoPath, ServerRepoConfig, StoragePathType, WebhookAuth, WebhookId,
}; };
use git_next_git::{self as git, forge::commit::Status, ForgeLike as _};
use assert2::let_assert; use assert2::let_assert;
use kxio::network::{self, MockNetwork, StatusCode}; use kxio::network::{self, MockNetwork, StatusCode};

View file

@ -1,6 +1,5 @@
// //
use git_next_core::{server::WebhookUrl, WebhookId}; use git_next_core::{git, server::WebhookUrl, WebhookId};
use git_next_git as git;
use kxio::network; use kxio::network;

View file

@ -1,6 +1,5 @@
// //
use git_next_core::{webhook, BranchName, WebhookId}; use git_next_core::{git, webhook, BranchName, WebhookId};
use git_next_git as git;
use std::collections::HashMap; use std::collections::HashMap;

View file

@ -1,8 +1,7 @@
// //
use crate as forgejo; use crate as forgejo;
use git_next_core::webhook; use git_next_core::{git, webhook};
use git_next_git as git;
pub fn parse_body( pub fn parse_body(
body: &webhook::forge_notification::Body, body: &webhook::forge_notification::Body,

View file

@ -1,6 +1,5 @@
// //
use git_next_core::{server, RegisteredWebhook, WebhookAuth, WebhookId}; use git_next_core::{git, server, RegisteredWebhook, WebhookAuth, WebhookId};
use git_next_git as git;
use kxio::network; use kxio::network;
use tracing::{info, warn}; use tracing::{info, warn};

View file

@ -1,6 +1,5 @@
// //
use git_next_core::WebhookId; use git_next_core::{git, WebhookId};
use git_next_git as git;
use kxio::network; use kxio::network;

View file

@ -1,7 +1,6 @@
// //
use crate::{self as github, GithubState}; use crate::{self as github, GithubState};
use git::forge::commit::Status; use git_next_core::git::{self, forge::commit::Status};
use git_next_git as git;
use github::GithubStatus; use github::GithubStatus;
use kxio::network; use kxio::network;

View file

@ -6,11 +6,11 @@ mod commit;
mod webhook; mod webhook;
use crate as github; use crate as github;
use git::forge::commit::Status;
use git_next_core::{ use git_next_core::{
self as core, server, ForgeNotification, RegisteredWebhook, WebhookAuth, WebhookId, self as core,
git::{self, forge::commit::Status},
server, ForgeNotification, RegisteredWebhook, WebhookAuth, WebhookId,
}; };
use git_next_git as git;
use derive_more::Constructor; use derive_more::Constructor;

View file

@ -1,13 +1,12 @@
// //
use crate::{Github, GithubState, GithubStatus}; use crate::{Github, GithubState, GithubStatus};
use git_next_core::{ use git_next_core::{
git::{self, forge::commit::Status, ForgeLike},
server::{InboundWebhook, WebhookUrl}, server::{InboundWebhook, WebhookUrl},
webhook, webhook::{self, forge_notification::Body},
webhook::forge_notification::Body,
ForgeAlias, ForgeConfig, ForgeNotification, ForgeType, GitDir, Hostname, RepoAlias, ForgeAlias, ForgeConfig, ForgeNotification, ForgeType, GitDir, Hostname, RepoAlias,
RepoBranches, RepoPath, ServerRepoConfig, StoragePathType, WebhookAuth, WebhookId, RepoBranches, RepoPath, ServerRepoConfig, StoragePathType, WebhookAuth, WebhookId,
}; };
use git_next_git::{self as git, forge::commit::Status, ForgeLike};
use assert2::let_assert; use assert2::let_assert;
use kxio::network::{self, MockNetwork, StatusCode}; use kxio::network::{self, MockNetwork, StatusCode};
@ -15,8 +14,7 @@ use rand::RngCore;
use serde::Serialize; use serde::Serialize;
use serde_json::json; use serde_json::json;
use std::collections::BTreeMap; use std::{collections::BTreeMap, path::PathBuf};
use std::path::PathBuf;
mod github { mod github {
use super::*; use super::*;

View file

@ -1,7 +1,6 @@
// //
use crate as github; use crate as github;
use git_next_core::{server, WebhookId}; use git_next_core::{git, server, WebhookId};
use git_next_git as git;
use kxio::network; use kxio::network;

View file

@ -1,6 +1,5 @@
// //
use git_next_core::{webhook, ApiToken, BranchName}; use git_next_core::{git, webhook, ApiToken, BranchName};
use git_next_git as git;
mod authorised; mod authorised;
mod list; mod list;

View file

@ -1,8 +1,7 @@
// //
use crate as github; use crate as github;
use git_next_core::webhook; use git_next_core::{git, webhook};
use git_next_git as git;
pub fn parse_body( pub fn parse_body(
body: &webhook::forge_notification::Body, body: &webhook::forge_notification::Body,

View file

@ -1,7 +1,6 @@
// //
use crate::{self as github, webhook}; use crate::{self as github, webhook};
use git_next_core::{server, RegisteredWebhook, WebhookAuth, WebhookId}; use git_next_core::{git, server, RegisteredWebhook, WebhookAuth, WebhookId};
use git_next_git as git;
use kxio::network; use kxio::network;

View file

@ -1,8 +1,6 @@
// //
use crate as github; use crate as github;
use git_next_core::{git, WebhookId};
use git_next_core::WebhookId;
use git_next_git as git;
use kxio::network; use kxio::network;

View file

@ -1,6 +1,5 @@
// //
use git_next_core::ForgeType; use git_next_core::{git, ForgeType};
use git_next_git as git;
use kxio::network::Network; use kxio::network::Network;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]

View file

@ -1,8 +1,11 @@
// //
use super::*; use super::*;
use git_next_core::{self as core, GitDir, RepoConfigSource, StoragePathType}; use git_next_core::{
use git_next_git::{self as git, RepoDetails}; self as core,
git::{self, RepoDetails},
GitDir, RepoConfigSource, StoragePathType,
};
#[test] #[test]
fn test_forgejo_name() { fn test_forgejo_name() {
@ -29,7 +32,7 @@ fn given_fs() -> kxio::fs::FileSystem {
fn given_repo_details(forge_type: ForgeType) -> RepoDetails { fn given_repo_details(forge_type: ForgeType) -> RepoDetails {
let fs = given_fs(); let fs = given_fs();
git::common::repo_details( git::repo_details(
1, 1,
git::Generation::default(), git::Generation::default(),
core::common::forge_details(1, forge_type), core::common::forge_details(1, forge_type),

View file

@ -4,47 +4,9 @@ version = { workspace = true }
edition = { workspace = true } edition = { workspace = true }
license = { workspace = true } license = { workspace = true }
repository = { workspace = true } repository = { workspace = true }
description = "git support for git-next, the trunk-based development manager" description = "[deprecated crate] git support for git-next, the trunk-based development manager"
[dependencies] [dependencies]
git-next-core = { workspace = true }
# logging
tracing = { workspace = true }
# git
gix = { workspace = true }
async-trait = { workspace = true }
# fs/network
kxio = { workspace = true }
# TOML parsing
serde_json = { workspace = true }
# webhooks - user notification
serde = { workspace = true }
# Secrets and Password
secrecy = { workspace = true }
# error handling
derive_more = { workspace = true }
derive-with = { workspace = true }
thiserror = { workspace = true }
# Actors
actix = { workspace = true }
mockall = { workspace = true }
[dev-dependencies]
# Testing
assert2 = { workspace = true }
rand = { workspace = true }
pretty_assertions = { workspace = true }
test-log = { workspace = true }
[lints.clippy] [lints.clippy]
nursery = { level = "warn", priority = -1 } nursery = { level = "warn", priority = -1 }

View file

@ -7,3 +7,5 @@ development workflows where each commit must pass CI before being included in
the main branch. the main branch.
See [git-next](https://crates.io/crates/git-next) for more information. See [git-next](https://crates.io/crates/git-next) for more information.
N.B. this crate has been merged into [git-next-core](https://crates.io/crates/git-next-core).

View file

@ -1,26 +0,0 @@
//
use git_next_core::{
common::{branch_name, repo_alias, repo_path},
ForgeDetails, GitDir, RepoConfig,
};
use crate::{Generation, RepoDetails};
pub fn repo_details(
n: u32,
generation: Generation,
forge: ForgeDetails,
repo_config: Option<RepoConfig>,
gitdir: GitDir,
) -> RepoDetails {
RepoDetails {
generation,
repo_alias: repo_alias(n),
repo_path: repo_path(n),
gitdir,
branch: branch_name(n),
forge,
repo_config,
}
}

View file

@ -1,28 +1 @@
// // moved to crates/core/src/git/
pub mod commit;
pub mod common;
pub mod fetch;
pub mod file;
pub mod forge;
mod generation;
mod git_ref;
mod git_remote;
pub mod push;
mod repo_details;
pub mod repository;
mod user_notification;
pub mod validation;
#[cfg(test)]
mod tests;
pub use commit::Commit;
pub use forge::like::ForgeLike;
pub use forge::like::MockForgeLike;
pub use generation::Generation;
pub use git_ref::GitRef;
pub use git_remote::GitRemote;
pub use repo_details::RepoDetails;
pub use repository::Repository;
pub use repository::RepositoryFactory;
pub use user_notification::UserNotification;

View file

@ -1,7 +1,9 @@
// //
use crate::messages::MessageToken; use crate::messages::MessageToken;
use git_next_core::RepoConfig; use git_next_core::{
use git_next_git::{self as git, repository::open::OpenRepositoryLike}; git::{self, repository::open::OpenRepositoryLike},
RepoConfig,
};
use derive_more::Display; use derive_more::Display;
use tracing::{info, warn}; use tracing::{info, warn};

View file

@ -1,40 +1,39 @@
// //
use actix::prelude::*; use actix::prelude::*;
use crate as actor; use git_next_core::git;
use git_next_git as git;
impl Handler<actor::messages::CloneRepo> for actor::RepoActor { impl Handler<crate::messages::CloneRepo> for crate::RepoActor {
type Result = (); type Result = ();
#[tracing::instrument(name = "RepoActor::CloneRepo", skip_all, fields(repo = %self.repo_details /*, gitdir = %self.repo_details.gitdir */))] #[tracing::instrument(name = "RepoActor::CloneRepo", skip_all, fields(repo = %self.repo_details /*, gitdir = %self.repo_details.gitdir */))]
fn handle( fn handle(
&mut self, &mut self,
_msg: actor::messages::CloneRepo, _msg: crate::messages::CloneRepo,
ctx: &mut Self::Context, ctx: &mut Self::Context,
) -> Self::Result { ) -> Self::Result {
actor::logger(self.log.as_ref(), "Handler: CloneRepo: start"); crate::logger(self.log.as_ref(), "Handler: CloneRepo: start");
tracing::debug!("Handler: CloneRepo: start"); tracing::debug!("Handler: CloneRepo: start");
match git::repository::open(&*self.repository_factory, &self.repo_details) { match git::repository::open(&*self.repository_factory, &self.repo_details) {
Ok(repository) => { Ok(repository) => {
actor::logger(self.log.as_ref(), "open okay"); crate::logger(self.log.as_ref(), "open okay");
tracing::debug!("open okay"); tracing::debug!("open okay");
self.open_repository.replace(repository); self.open_repository.replace(repository);
if self.repo_details.repo_config.is_none() { if self.repo_details.repo_config.is_none() {
actor::do_send( crate::do_send(
ctx.address(), ctx.address(),
actor::messages::LoadConfigFromRepo, crate::messages::LoadConfigFromRepo,
self.log.as_ref(), self.log.as_ref(),
); );
} else { } else {
actor::do_send( crate::do_send(
ctx.address(), ctx.address(),
actor::messages::RegisterWebhook::new(), crate::messages::RegisterWebhook::new(),
self.log.as_ref(), self.log.as_ref(),
); );
} }
} }
Err(err) => { Err(err) => {
actor::logger(self.log.as_ref(), "open failed"); crate::logger(self.log.as_ref(), "open failed");
tracing::debug!("err: {err:?}"); tracing::debug!("err: {err:?}");
tracing::warn!("Could not open repo: {err}") tracing::warn!("Could not open repo: {err}")
} }

View file

@ -1,16 +1,16 @@
// //
use actix::prelude::*; use actix::prelude::*;
use git_next_git::UserNotification;
use git_next_core::git::UserNotification;
use tracing::Instrument as _; use tracing::Instrument as _;
use crate::{self as actor}; impl Handler<crate::messages::LoadConfigFromRepo> for crate::RepoActor {
impl Handler<actor::messages::LoadConfigFromRepo> for actor::RepoActor {
type Result = (); type Result = ();
#[tracing::instrument(name = "RepoActor::LoadConfigFromRepo", skip_all, fields(repo = %self.repo_details))] #[tracing::instrument(name = "Repocrate::LoadConfigFromRepo", skip_all, fields(repo = %self.repo_details))]
fn handle( fn handle(
&mut self, &mut self,
_msg: actor::messages::LoadConfigFromRepo, _msg: crate::messages::LoadConfigFromRepo,
ctx: &mut Self::Context, ctx: &mut Self::Context,
) -> Self::Result { ) -> Self::Result {
tracing::debug!("Handler: LoadConfigFromRepo: start"); tracing::debug!("Handler: LoadConfigFromRepo: start");
@ -25,13 +25,13 @@ impl Handler<actor::messages::LoadConfigFromRepo> for actor::RepoActor {
let notify_user_recipient = self.notify_user_recipient.clone(); let notify_user_recipient = self.notify_user_recipient.clone();
let log = self.log.clone(); let log = self.log.clone();
async move { async move {
match actor::load::config_from_repository(repo_details, &*open_repository).await { match crate::load::config_from_repository(repo_details, &*open_repository).await {
Ok(repo_config) => actor::do_send( Ok(repo_config) => crate::do_send(
addr, addr,
actor::messages::ReceiveRepoConfig::new(repo_config), crate::messages::ReceiveRepoConfig::new(repo_config),
log.as_ref(), log.as_ref(),
), ),
Err(err) => actor::notify_user( Err(err) => crate::notify_user(
notify_user_recipient.as_ref(), notify_user_recipient.as_ref(),
UserNotification::RepoConfigLoadFailure { UserNotification::RepoConfigLoadFailure {
forge_alias, forge_alias,

View file

@ -1,19 +1,18 @@
// //
use crate::{self as actor};
use actix::prelude::*; use actix::prelude::*;
use git::UserNotification;
use git_next_git as git;
impl Handler<actor::messages::ReceiveCIStatus> for actor::RepoActor { use git_next_core::git::{self, UserNotification};
impl Handler<crate::messages::ReceiveCIStatus> for crate::RepoActor {
type Result = (); type Result = ();
fn handle( fn handle(
&mut self, &mut self,
msg: actor::messages::ReceiveCIStatus, msg: crate::messages::ReceiveCIStatus,
ctx: &mut Self::Context, ctx: &mut Self::Context,
) -> Self::Result { ) -> Self::Result {
let log = self.log.clone(); let log = self.log.clone();
actor::logger(log.as_ref(), "start: ReceiveCIStatus"); crate::logger(log.as_ref(), "start: ReceiveCIStatus");
let addr = ctx.address(); let addr = ctx.address();
let (next, status) = msg.unwrap(); let (next, status) = msg.unwrap();
let forge_alias = self.repo_details.forge.forge_alias().clone(); let forge_alias = self.repo_details.forge.forge_alias().clone();
@ -24,23 +23,23 @@ impl Handler<actor::messages::ReceiveCIStatus> for actor::RepoActor {
tracing::debug!(?status, ""); tracing::debug!(?status, "");
match status { match status {
git::forge::commit::Status::Pass => { git::forge::commit::Status::Pass => {
actor::do_send( crate::do_send(
addr, addr,
actor::messages::AdvanceMain::new(next), crate::messages::AdvanceMain::new(next),
self.log.as_ref(), self.log.as_ref(),
); );
} }
git::forge::commit::Status::Pending => { git::forge::commit::Status::Pending => {
std::thread::sleep(sleep_duration); std::thread::sleep(sleep_duration);
actor::do_send( crate::do_send(
addr, addr,
actor::messages::ValidateRepo::new(message_token), crate::messages::ValidateRepo::new(message_token),
self.log.as_ref(), self.log.as_ref(),
); );
} }
git::forge::commit::Status::Fail => { git::forge::commit::Status::Fail => {
tracing::warn!("Checks have failed"); tracing::warn!("Checks have failed");
actor::notify_user( crate::notify_user(
self.notify_user_recipient.as_ref(), self.notify_user_recipient.as_ref(),
UserNotification::CICheckFailed { UserNotification::CICheckFailed {
forge_alias, forge_alias,
@ -49,10 +48,10 @@ impl Handler<actor::messages::ReceiveCIStatus> for actor::RepoActor {
}, },
log.as_ref(), log.as_ref(),
); );
actor::delay_send( crate::delay_send(
addr, addr,
sleep_duration, sleep_duration,
actor::messages::ValidateRepo::new(message_token), crate::messages::ValidateRepo::new(message_token),
self.log.as_ref(), self.log.as_ref(),
); );
} }

View file

@ -2,9 +2,8 @@
use actix::prelude::*; use actix::prelude::*;
use tracing::Instrument as _; use tracing::Instrument as _;
use crate::{self as actor}; use crate::{messages::RegisterWebhook, RepoActor};
use actor::{messages::RegisterWebhook, RepoActor}; use git_next_core::git::UserNotification;
use git_next_git::UserNotification;
impl Handler<RegisterWebhook> for RepoActor { impl Handler<RegisterWebhook> for RepoActor {
type Result = (); type Result = ();
@ -23,14 +22,14 @@ impl Handler<RegisterWebhook> for RepoActor {
match forge.register_webhook(&webhook_url).await { match forge.register_webhook(&webhook_url).await {
Ok(registered_webhook) => { Ok(registered_webhook) => {
tracing::debug!(?registered_webhook, ""); tracing::debug!(?registered_webhook, "");
actor::do_send( crate::do_send(
addr, addr,
actor::messages::WebhookRegistered::from(registered_webhook), crate::messages::WebhookRegistered::from(registered_webhook),
log.as_ref(), log.as_ref(),
); );
} }
Err(err) => { Err(err) => {
actor::notify_user( crate::notify_user(
notify_user_recipient.as_ref(), notify_user_recipient.as_ref(),
UserNotification::WebhookRegistration { UserNotification::WebhookRegistration {
forge_alias, forge_alias,

View file

@ -1,26 +1,27 @@
// //
use actix::prelude::*; use actix::prelude::*;
use derive_more::Deref as _; use derive_more::Deref as _;
use tracing::Instrument as _; use tracing::Instrument as _;
use crate::{self as actor, messages::MessageToken}; use crate::messages::MessageToken;
use git_next_git as git; use git_next_core::git;
impl Handler<actor::messages::ValidateRepo> for actor::RepoActor { impl Handler<crate::messages::ValidateRepo> for crate::RepoActor {
type Result = (); type Result = ();
#[tracing::instrument(name = "RepoActor::ValidateRepo", skip_all, fields(repo = %self.repo_details, token = %msg.deref()))] #[tracing::instrument(name = "RepoActor::ValidateRepo", skip_all, fields(repo = %self.repo_details, token = %msg.deref()))]
fn handle( fn handle(
&mut self, &mut self,
msg: actor::messages::ValidateRepo, msg: crate::messages::ValidateRepo,
ctx: &mut Self::Context, ctx: &mut Self::Context,
) -> Self::Result { ) -> Self::Result {
actor::logger(self.log.as_ref(), "start: ValidateRepo"); crate::logger(self.log.as_ref(), "start: ValidateRepo");
// Message Token - make sure we are only triggered for the latest/current token // Message Token - make sure we are only triggered for the latest/current token
match self.token_status(msg.unwrap()) { match self.token_status(msg.unwrap()) {
TokenStatus::Current => {} // do nothing TokenStatus::Current => {} // do nothing
TokenStatus::Expired => { TokenStatus::Expired => {
actor::logger( crate::logger(
self.log.as_ref(), self.log.as_ref(),
format!("discarded: old message token: {}", self.message_token), format!("discarded: old message token: {}", self.message_token),
); );
@ -28,28 +29,28 @@ impl Handler<actor::messages::ValidateRepo> for actor::RepoActor {
} }
TokenStatus::New(message_token) => { TokenStatus::New(message_token) => {
self.message_token = message_token; self.message_token = message_token;
actor::logger( crate::logger(
self.log.as_ref(), self.log.as_ref(),
format!("new message token: {}", self.message_token), format!("new message token: {}", self.message_token),
); );
} }
} }
actor::logger( crate::logger(
self.log.as_ref(), self.log.as_ref(),
format!("accepted token: {}", self.message_token), format!("accepted token: {}", self.message_token),
); );
// Repository positions // Repository positions
let Some(ref open_repository) = self.open_repository else { let Some(ref open_repository) = self.open_repository else {
actor::logger(self.log.as_ref(), "no open repository"); crate::logger(self.log.as_ref(), "no open repository");
return; return;
}; };
actor::logger(self.log.as_ref(), "have open repository"); crate::logger(self.log.as_ref(), "have open repository");
let Some(repo_config) = self.repo_details.repo_config.clone() else { let Some(repo_config) = self.repo_details.repo_config.clone() else {
actor::logger(self.log.as_ref(), "no repo config"); crate::logger(self.log.as_ref(), "no repo config");
return; return;
}; };
actor::logger(self.log.as_ref(), "have repo config"); crate::logger(self.log.as_ref(), "have repo config");
match git::validation::positions::validate_positions( match git::validation::positions::validate_positions(
&**open_repository, &**open_repository,
@ -64,15 +65,15 @@ impl Handler<actor::messages::ValidateRepo> for actor::RepoActor {
}) => { }) => {
tracing::debug!(%main, %next, %dev, "positions"); tracing::debug!(%main, %next, %dev, "positions");
if next != main { if next != main {
actor::do_send( crate::do_send(
ctx.address(), ctx.address(),
actor::messages::CheckCIStatus::new(next), crate::messages::CheckCIStatus::new(next),
self.log.as_ref(), self.log.as_ref(),
); );
} else if next != dev { } else if next != dev {
actor::do_send( crate::do_send(
ctx.address(), ctx.address(),
actor::messages::AdvanceNext::new((next, dev_commit_history)), crate::messages::AdvanceNext::new((next, dev_commit_history)),
self.log.as_ref(), self.log.as_ref(),
) )
} else { } else {
@ -80,19 +81,19 @@ impl Handler<actor::messages::ValidateRepo> for actor::RepoActor {
} }
} }
Err(git::validation::positions::Error::Retryable(message)) => { Err(git::validation::positions::Error::Retryable(message)) => {
actor::logger(self.log.as_ref(), message); crate::logger(self.log.as_ref(), message);
let addr = ctx.address(); let addr = ctx.address();
let message_token = self.message_token; let message_token = self.message_token;
let sleep_duration = self.sleep_duration; let sleep_duration = self.sleep_duration;
let log = self.log.clone(); let log = self.log.clone();
async move { async move {
tracing::debug!("sleeping before retrying..."); tracing::debug!("sleeping before retrying...");
actor::logger(log.as_ref(), "before sleep"); crate::logger(log.as_ref(), "before sleep");
tokio::time::sleep(sleep_duration).await; tokio::time::sleep(sleep_duration).await;
actor::logger(log.as_ref(), "after sleep"); crate::logger(log.as_ref(), "after sleep");
actor::do_send( crate::do_send(
addr, addr,
actor::messages::ValidateRepo::new(message_token), crate::messages::ValidateRepo::new(message_token),
log.as_ref(), log.as_ref(),
); );
} }
@ -101,14 +102,14 @@ impl Handler<actor::messages::ValidateRepo> for actor::RepoActor {
.wait(ctx); .wait(ctx);
} }
Err(git::validation::positions::Error::UserIntervention(user_notification)) => { Err(git::validation::positions::Error::UserIntervention(user_notification)) => {
actor::notify_user( crate::notify_user(
self.notify_user_recipient.as_ref(), self.notify_user_recipient.as_ref(),
user_notification, user_notification,
self.log.as_ref(), self.log.as_ref(),
) )
} }
Err(git::validation::positions::Error::NonRetryable(message)) => { Err(git::validation::positions::Error::NonRetryable(message)) => {
actor::logger(self.log.as_ref(), message); crate::logger(self.log.as_ref(), message);
} }
} }
} }
@ -119,7 +120,7 @@ enum TokenStatus {
Expired, Expired,
New(MessageToken), New(MessageToken),
} }
impl actor::RepoActor { impl crate::RepoActor {
fn token_status(&self, new: MessageToken) -> TokenStatus { fn token_status(&self, new: MessageToken) -> TokenStatus {
let current = &self.message_token; let current = &self.message_token;
if &new > current { if &new > current {

View file

@ -1,22 +1,22 @@
// //
use actix::prelude::*; use actix::prelude::*;
use crate::{self as actor, messages::WebhookNotification, RepoActorLog}; use crate::{messages::WebhookNotification, RepoActorLog};
use git_next_core::{ use git_next_core::{
git::{self, Commit, ForgeLike},
webhook::{push::Branch, Push}, webhook::{push::Branch, Push},
BranchName, WebhookAuth, BranchName, WebhookAuth,
}; };
use git_next_git::{self as git, Commit, ForgeLike};
use tracing::{info, warn}; use tracing::{info, warn};
impl Handler<WebhookNotification> for actor::RepoActor { impl Handler<WebhookNotification> for crate::RepoActor {
type Result = (); type Result = ();
#[tracing::instrument(name = "RepoActor::WebhookMessage", skip_all, fields(token = %self.message_token, repo = %self.repo_details))] #[tracing::instrument(name = "RepoActor::WebhookMessage", skip_all, fields(token = %self.message_token, repo = %self.repo_details))]
fn handle(&mut self, msg: WebhookNotification, ctx: &mut Self::Context) -> Self::Result { fn handle(&mut self, msg: WebhookNotification, ctx: &mut Self::Context) -> Self::Result {
let Some(config) = &self.repo_details.repo_config else { let Some(config) = &self.repo_details.repo_config else {
actor::logger(self.log.as_ref(), "server has no repo config"); crate::logger(self.log.as_ref(), "server has no repo config");
warn!("No repo config"); warn!("No repo config");
return; return;
}; };
@ -33,13 +33,13 @@ impl Handler<WebhookNotification> for actor::RepoActor {
let body = msg.body(); let body = msg.body();
match self.forge.parse_webhook_body(body) { match self.forge.parse_webhook_body(body) {
Err(err) => { Err(err) => {
actor::logger(self.log.as_ref(), "message parse error - not a push"); crate::logger(self.log.as_ref(), "message parse error - not a push");
warn!(?err, "Not a 'push'"); warn!(?err, "Not a 'push'");
return; return;
} }
Ok(push) => match push.branch(config.branches()) { Ok(push) => match push.branch(config.branches()) {
None => { None => {
actor::logger(self.log.as_ref(), "unknown branch"); crate::logger(self.log.as_ref(), "unknown branch");
warn!( warn!(
?push, ?push,
"Unrecognised branch, we should be filtering to only the ones we want" "Unrecognised branch, we should be filtering to only the ones we want"
@ -89,9 +89,9 @@ impl Handler<WebhookNotification> for actor::RepoActor {
token = %message_token, token = %message_token,
"New commit" "New commit"
); );
actor::do_send( crate::do_send(
ctx.address(), ctx.address(),
actor::messages::ValidateRepo::new(message_token), crate::messages::ValidateRepo::new(message_token),
self.log.as_ref(), self.log.as_ref(),
); );
} }
@ -104,13 +104,13 @@ fn validate_notification(
log: Option<&RepoActorLog>, log: Option<&RepoActorLog>,
) -> Result<(), ()> { ) -> Result<(), ()> {
let Some(expected_authorization) = webhook_auth else { let Some(expected_authorization) = webhook_auth else {
actor::logger(log, "server has no auth token"); crate::logger(log, "server has no auth token");
warn!("Don't know what authorization to expect"); warn!("Don't know what authorization to expect");
return Err(()); return Err(());
}; };
if !forge.is_message_authorised(msg, expected_authorization) { if !forge.is_message_authorised(msg, expected_authorization) {
actor::logger(log, "message authorisation is invalid"); crate::logger(log, "message authorisation is invalid");
warn!( warn!(
"Invalid authorization - expected {}", "Invalid authorization - expected {}",
expected_authorization expected_authorization
@ -118,7 +118,7 @@ fn validate_notification(
return Err(()); return Err(());
} }
if forge.should_ignore_message(msg) { if forge.should_ignore_message(msg) {
actor::logger(log, "forge sent ignorable message"); crate::logger(log, "forge sent ignorable message");
return Err(()); return Err(());
} }
Ok(()) Ok(())
@ -130,10 +130,10 @@ fn handle_push(
last_commit: &mut Option<Commit>, last_commit: &mut Option<Commit>,
log: Option<&RepoActorLog>, log: Option<&RepoActorLog>,
) -> Result<(), ()> { ) -> Result<(), ()> {
actor::logger(log, "message is for dev branch"); crate::logger(log, "message is for dev branch");
let commit = git::Commit::from(push); let commit = git::Commit::from(push);
if last_commit.as_ref() == Some(&commit) { if last_commit.as_ref() == Some(&commit) {
actor::logger(log, format!("not a new commit on {branch}")); crate::logger(log, format!("not a new commit on {branch}"));
info!( info!(
%branch , %branch ,
%commit, %commit,

View file

@ -7,11 +7,13 @@ use messages::NotifyUser;
use std::time::Duration; use std::time::Duration;
use tracing::{info, warn, Instrument}; use tracing::{info, warn, Instrument};
use git_next_core::{server, WebhookAuth, WebhookId}; use git_next_core::{
use git_next_git::{ git::{
self as git, self,
repository::{factory::RepositoryFactory, open::OpenRepositoryLike}, repository::{factory::RepositoryFactory, open::OpenRepositoryLike},
UserNotification, UserNotification,
},
server, WebhookAuth, WebhookId,
}; };
mod branch; mod branch;

View file

@ -1,6 +1,8 @@
// //
use git_next_core::{server, BranchName, RepoConfig}; use git_next_core::{
use git_next_git::{self as git, repository::open::OpenRepositoryLike}; git::{self, repository::open::OpenRepositoryLike},
server, BranchName, RepoConfig,
};
use std::path::PathBuf; use std::path::PathBuf;

View file

@ -1,10 +1,8 @@
// //
use derive_more::Display; use derive_more::Display;
use git::UserNotification;
use git_next_git as git;
use git_next_core::{ use git_next_core::{
git::{self, UserNotification},
message, newtype, webhook, RegisteredWebhook, RepoConfig, WebhookAuth, WebhookId, message, newtype, webhook, RegisteredWebhook, RepoConfig, WebhookAuth, WebhookId,
}; };

View file

@ -1,8 +1,9 @@
use derive_more::Deref as _; use derive_more::Deref as _;
use git_next_git::UserNotification;
use serde_json::json;
use crate::messages::NotifyUser; use crate::messages::NotifyUser;
use git_next_core::git::UserNotification;
use serde_json::json;
impl NotifyUser { impl NotifyUser {
pub fn as_json(self, timestamp: time::OffsetDateTime) -> serde_json::Value { pub fn as_json(self, timestamp: time::OffsetDateTime) -> serde_json::Value {

View file

@ -11,11 +11,11 @@ fn push_is_error_should_error() {
expect::push(&mut open_repository, Err(git::push::Error::Lock)); expect::push(&mut open_repository, Err(git::push::Error::Lock));
let_assert!( let_assert!(
Err(err) = Err(err) =
actor::branch::advance_main(commit, &repo_details, &repo_config, &open_repository) crate::branch::advance_main(commit, &repo_details, &repo_config, &open_repository)
); );
assert!(matches!( assert!(matches!(
err, err,
actor::branch::Error::Push(git::push::Error::Lock) crate::branch::Error::Push(git::push::Error::Lock)
)); ));
} }
@ -28,6 +28,6 @@ fn push_is_ok_should_ok() {
expect::fetch_ok(&mut open_repository); expect::fetch_ok(&mut open_repository);
expect::push_ok(&mut open_repository); expect::push_ok(&mut open_repository);
assert!( assert!(
actor::branch::advance_main(commit, &repo_details, &repo_config, &open_repository).is_ok() crate::branch::advance_main(commit, &repo_details, &repo_config, &open_repository).is_ok()
); );
} }

View file

@ -14,7 +14,7 @@ mod when_at_dev {
// no on_push defined - so any call to push will cause an error // no on_push defined - so any call to push will cause an error
let message_token = given::a_message_token(); let message_token = given::a_message_token();
let_assert!( let_assert!(
Err(err) = actor::branch::advance_next( Err(err) = crate::branch::advance_next(
&next, &next,
dev_commit_history, dev_commit_history,
repo_details, repo_details,
@ -24,7 +24,7 @@ mod when_at_dev {
) )
); );
tracing::debug!("Got: {err}"); tracing::debug!("Got: {err}");
assert!(matches!(err, actor::branch::Error::NextAtDev)); assert!(matches!(err, crate::branch::Error::NextAtDev));
Ok(()) Ok(())
} }
} }
@ -47,7 +47,7 @@ mod can_advance {
// no on_push defined - so any call to push will cause an error // no on_push defined - so any call to push will cause an error
let message_token = given::a_message_token(); let message_token = given::a_message_token();
let_assert!( let_assert!(
Err(err) = actor::branch::advance_next( Err(err) = crate::branch::advance_next(
&next, &next,
dev_commit_history, dev_commit_history,
repo_details, repo_details,
@ -57,7 +57,7 @@ mod can_advance {
) )
); );
tracing::debug!("Got: {err}"); tracing::debug!("Got: {err}");
assert!(matches!(err, actor::branch::Error::IsWorkInProgress)); assert!(matches!(err, crate::branch::Error::IsWorkInProgress));
Ok(()) Ok(())
} }
} }
@ -77,7 +77,7 @@ mod can_advance {
// no on_push defined - so any call to push will cause an error // no on_push defined - so any call to push will cause an error
let message_token = given::a_message_token(); let message_token = given::a_message_token();
let_assert!( let_assert!(
Err(err) = actor::branch::advance_next( Err(err) = crate::branch::advance_next(
&next, &next,
dev_commit_history, dev_commit_history,
repo_details, repo_details,
@ -89,7 +89,7 @@ mod can_advance {
tracing::debug!("Got: {err}"); tracing::debug!("Got: {err}");
assert!(matches!( assert!(matches!(
err, err,
actor::branch::Error::InvalidCommitMessage{reason} crate::branch::Error::InvalidCommitMessage{reason}
if reason == "Missing type in the commit summary, expected `type: description`" if reason == "Missing type in the commit summary, expected `type: description`"
)); ));
Ok(()) Ok(())
@ -116,7 +116,7 @@ mod can_advance {
expect::push(&mut open_repository, Err(git::push::Error::Lock)); expect::push(&mut open_repository, Err(git::push::Error::Lock));
let message_token = given::a_message_token(); let message_token = given::a_message_token();
let_assert!( let_assert!(
Err(err) = actor::branch::advance_next( Err(err) = crate::branch::advance_next(
&next, &next,
dev_commit_history, dev_commit_history,
repo_details, repo_details,
@ -128,7 +128,7 @@ mod can_advance {
tracing::debug!("Got: {err:?}"); tracing::debug!("Got: {err:?}");
assert!(matches!( assert!(matches!(
err, err,
actor::branch::Error::Push(git::push::Error::Lock) crate::branch::Error::Push(git::push::Error::Lock)
)); ));
Ok(()) Ok(())
} }
@ -150,7 +150,7 @@ mod can_advance {
expect::push_ok(&mut open_repository); expect::push_ok(&mut open_repository);
let message_token = given::a_message_token(); let message_token = given::a_message_token();
let_assert!( let_assert!(
Ok(mt) = actor::branch::advance_next( Ok(mt) = crate::branch::advance_next(
&next, &next,
dev_commit_history, dev_commit_history,
repo_details, repo_details,

View file

@ -15,7 +15,7 @@ async fn test_find_next_commit_on_dev() {
given::a_commit(), // parent of next given::a_commit(), // parent of next
]; ];
let next_commit = actor::branch::find_next_commit_on_dev(&next, &dev_commit_history); let next_commit = crate::branch::find_next_commit_on_dev(&next, &dev_commit_history);
assert_eq!(next_commit, Some(expected), "Found the wrong commit"); assert_eq!(next_commit, Some(expected), "Found the wrong commit");
} }

View file

@ -186,7 +186,7 @@ pub fn a_repo_actor(
repository_factory: Box<dyn RepositoryFactory>, repository_factory: Box<dyn RepositoryFactory>,
forge: Box<dyn git::ForgeLike>, forge: Box<dyn git::ForgeLike>,
net: kxio::network::Network, net: kxio::network::Network,
) -> (actor::RepoActor, RepoActorLog) { ) -> (crate::RepoActor, RepoActorLog) {
let forge_alias = repo_details.forge.forge_alias(); let forge_alias = repo_details.forge.forge_alias();
let repo_alias = &repo_details.repo_alias; let repo_alias = &repo_details.repo_alias;
let webhook_url = given::a_webhook_url(forge_alias, repo_alias); let webhook_url = given::a_webhook_url(forge_alias, repo_alias);
@ -195,7 +195,7 @@ pub fn a_repo_actor(
let log = RepoActorLog::default(); let log = RepoActorLog::default();
let actors_log = log.clone(); let actors_log = log.clone();
( (
actor::RepoActor::new( crate::RepoActor::new(
repo_details, repo_details,
forge, forge,
webhook, webhook,

View file

@ -32,7 +32,7 @@ async fn when_repo_config_should_fetch_then_push_then_revalidate() -> TestResult
repo_details, repo_details,
given::a_forge(), given::a_forge(),
); );
addr.send(actor::messages::AdvanceMain::new(next_commit.clone())) addr.send(crate::messages::AdvanceMain::new(next_commit.clone()))
.await?; .await?;
System::current().stop(); System::current().stop();
@ -77,7 +77,7 @@ async fn when_server_config_should_fetch_then_push_then_revalidate() -> TestResu
repo_details, repo_details,
given::a_forge(), given::a_forge(),
); );
addr.send(actor::messages::AdvanceMain::new(next_commit.clone())) addr.send(crate::messages::AdvanceMain::new(next_commit.clone()))
.await?; .await?;
System::current().stop(); System::current().stop();

View file

@ -31,7 +31,7 @@ async fn should_fetch_then_push_then_revalidate() -> TestResult {
repo_details, repo_details,
given::a_forge(), given::a_forge(),
); );
addr.send(actor::messages::AdvanceNext::new(( addr.send(crate::messages::AdvanceNext::new((
next_commit.clone(), next_commit.clone(),
dev_commit_log, dev_commit_log,
))) )))

View file

@ -20,7 +20,7 @@ async fn should_passthrough_to_receive_ci_status() -> TestResult {
repo_details, repo_details,
Box::new(forge), Box::new(forge),
); );
addr.send(actor::messages::CheckCIStatus::new(next_commit.clone())) addr.send(crate::messages::CheckCIStatus::new(next_commit.clone()))
.await?; .await?;
System::current().stop(); System::current().stop();

View file

@ -39,7 +39,7 @@ async fn when_read_file_ok_should_send_config_loaded() -> TestResult {
repo_details, repo_details,
given::a_forge(), given::a_forge(),
); );
addr.send(actor::messages::LoadConfigFromRepo::new()) addr.send(crate::messages::LoadConfigFromRepo::new())
.await?; .await?;
System::current().stop(); System::current().stop();
@ -70,7 +70,7 @@ async fn when_read_file_err_should_notify_user() -> TestResult {
repo_details, repo_details,
given::a_forge(), given::a_forge(),
); );
addr.send(actor::messages::LoadConfigFromRepo::new()) addr.send(crate::messages::LoadConfigFromRepo::new())
.await?; .await?;
System::current().stop(); System::current().stop();

View file

@ -15,7 +15,7 @@ async fn should_store_repo_config_in_actor() -> TestResult {
repo_details, repo_details,
given::a_forge(), given::a_forge(),
); );
addr.send(actor::messages::ReceiveRepoConfig::new( addr.send(crate::messages::ReceiveRepoConfig::new(
new_repo_config.clone(), new_repo_config.clone(),
)) ))
.await?; .await?;
@ -46,7 +46,7 @@ async fn should_register_webhook() -> TestResult {
repo_details, repo_details,
given::a_forge(), given::a_forge(),
); );
addr.send(actor::messages::ReceiveRepoConfig::new( addr.send(crate::messages::ReceiveRepoConfig::new(
new_repo_config.clone(), new_repo_config.clone(),
)) ))
.await?; .await?;

View file

@ -14,7 +14,7 @@ async fn when_pass_should_advance_main_to_next() -> TestResult {
repo_details, repo_details,
given::a_forge(), given::a_forge(),
); );
addr.send(actor::messages::ReceiveCIStatus::new(( addr.send(crate::messages::ReceiveCIStatus::new((
next_commit.clone(), next_commit.clone(),
git::forge::commit::Status::Pass, git::forge::commit::Status::Pass,
))) )))
@ -44,7 +44,7 @@ async fn when_pending_should_recheck_ci_status() -> TestResult {
repo_details, repo_details,
given::a_forge(), given::a_forge(),
); );
addr.send(actor::messages::ReceiveCIStatus::new(( addr.send(crate::messages::ReceiveCIStatus::new((
next_commit.clone(), next_commit.clone(),
git::forge::commit::Status::Pending, git::forge::commit::Status::Pending,
))) )))
@ -74,7 +74,7 @@ async fn when_fail_should_recheck_after_delay() -> TestResult {
repo_details, repo_details,
given::a_forge(), given::a_forge(),
); );
addr.send(actor::messages::ReceiveCIStatus::new(( addr.send(crate::messages::ReceiveCIStatus::new((
next_commit.clone(), next_commit.clone(),
git::forge::commit::Status::Fail, git::forge::commit::Status::Fail,
))) )))
@ -100,7 +100,7 @@ async fn when_fail_should_notify_user() -> TestResult {
repo_details, repo_details,
given::a_forge(), given::a_forge(),
); );
addr.send(actor::messages::ReceiveCIStatus::new(( addr.send(crate::messages::ReceiveCIStatus::new((
next_commit.clone(), next_commit.clone(),
git::forge::commit::Status::Fail, git::forge::commit::Status::Fail,
))) )))

View file

@ -22,7 +22,7 @@ async fn when_registered_ok_should_send_webhook_registered() -> TestResult {
repo_details, repo_details,
Box::new(forge), Box::new(forge),
); );
addr.send(actor::messages::RegisterWebhook::new()).await?; addr.send(crate::messages::RegisterWebhook::new()).await?;
System::current().stop(); System::current().stop();
//then //then
@ -57,7 +57,7 @@ async fn when_registered_error_should_send_notify_user() -> TestResult {
repo_details, repo_details,
Box::new(forge), Box::new(forge),
); );
addr.send(actor::messages::RegisterWebhook::new()).await?; addr.send(crate::messages::RegisterWebhook::new()).await?;
System::current().stop(); System::current().stop();
//then //then

View file

@ -23,7 +23,7 @@ async fn when_no_expected_auth_token_drop_notification() -> TestResult {
//when //when
actor actor
.start() .start()
.send(actor::messages::WebhookNotification::new( .send(crate::messages::WebhookNotification::new(
forge_notification, forge_notification,
)) ))
.await?; .await?;
@ -57,7 +57,7 @@ async fn when_no_repo_config_drop_notification() -> TestResult {
//when //when
actor actor
.start() .start()
.send(actor::messages::WebhookNotification::new( .send(crate::messages::WebhookNotification::new(
forge_notification, forge_notification,
)) ))
.await?; .await?;
@ -95,7 +95,7 @@ async fn when_message_auth_is_invalid_drop_notification() -> TestResult {
//when //when
actor actor
.start() .start()
.send(actor::messages::WebhookNotification::new( .send(crate::messages::WebhookNotification::new(
forge_notification, forge_notification,
)) ))
.await?; .await?;
@ -137,7 +137,7 @@ async fn when_message_is_ignorable_drop_notification() -> TestResult {
//when //when
actor actor
.start() .start()
.send(actor::messages::WebhookNotification::new( .send(crate::messages::WebhookNotification::new(
forge_notification, forge_notification,
)) ))
.await?; .await?;
@ -179,7 +179,7 @@ async fn when_message_is_not_a_push_drop_notification() -> TestResult {
//when //when
actor actor
.start() .start()
.send(actor::messages::WebhookNotification::new( .send(crate::messages::WebhookNotification::new(
forge_notification, forge_notification,
)) ))
.await?; .await?;
@ -227,7 +227,7 @@ async fn when_message_is_push_on_unknown_branch_drop_notification() -> TestResul
//when //when
actor actor
.start() .start()
.send(actor::messages::WebhookNotification::new( .send(crate::messages::WebhookNotification::new(
forge_notification, forge_notification,
)) ))
.await?; .await?;
@ -276,7 +276,7 @@ async fn when_message_is_push_already_seen_commit_to_main() -> TestResult {
//when //when
actor actor
.start() .start()
.send(actor::messages::WebhookNotification::new( .send(crate::messages::WebhookNotification::new(
forge_notification, forge_notification,
)) ))
.await?; .await?;
@ -325,7 +325,7 @@ async fn when_message_is_push_already_seen_commit_to_next() -> TestResult {
//when //when
actor actor
.start() .start()
.send(actor::messages::WebhookNotification::new( .send(crate::messages::WebhookNotification::new(
forge_notification, forge_notification,
)) ))
.await?; .await?;
@ -374,7 +374,7 @@ async fn when_message_is_push_already_seen_commit_to_dev() -> TestResult {
//when //when
actor actor
.start() .start()
.send(actor::messages::WebhookNotification::new( .send(crate::messages::WebhookNotification::new(
forge_notification, forge_notification,
)) ))
.await?; .await?;
@ -421,7 +421,7 @@ async fn when_message_is_push_new_commit_to_main_should_stash_and_validate_repo(
//when //when
let addr = actor.start(); let addr = actor.start();
addr.send(actor::messages::WebhookNotification::new( addr.send(crate::messages::WebhookNotification::new(
forge_notification, forge_notification,
)) ))
.await?; .await?;
@ -469,7 +469,7 @@ async fn when_message_is_push_new_commit_to_next_should_stash_and_validate_repo(
//when //when
let addr = actor.start(); let addr = actor.start();
addr.send(actor::messages::WebhookNotification::new( addr.send(crate::messages::WebhookNotification::new(
forge_notification, forge_notification,
)) ))
.await?; .await?;
@ -517,7 +517,7 @@ async fn when_message_is_push_new_commit_to_dev_should_stash_and_validate_repo()
//when //when
let addr = actor.start(); let addr = actor.start();
addr.send(actor::messages::WebhookNotification::new( addr.send(crate::messages::WebhookNotification::new(
forge_notification, forge_notification,
)) ))
.await?; .await?;

View file

@ -15,7 +15,7 @@ async fn should_store_webhook_details() -> TestResult {
repo_details, repo_details,
given::a_forge(), given::a_forge(),
); );
addr.send(actor::messages::WebhookRegistered::new(( addr.send(crate::messages::WebhookRegistered::new((
webhook_id.clone(), webhook_id.clone(),
webhook_auth.clone(), webhook_auth.clone(),
))) )))
@ -43,7 +43,7 @@ async fn should_send_validate_repo_message() -> TestResult {
repo_details, repo_details,
given::a_forge(), given::a_forge(),
); );
addr.send(actor::messages::WebhookRegistered::new(( addr.send(crate::messages::WebhookRegistered::new((
webhook_id.clone(), webhook_id.clone(),
webhook_auth.clone(), webhook_auth.clone(),
))) )))

View file

@ -11,13 +11,13 @@ async fn when_file_not_found_should_error() -> TestResult {
.returning(|_, _| Err(git::file::Error::FileNotFound)); .returning(|_, _| Err(git::file::Error::FileNotFound));
//when //when
let_assert!( let_assert!(
Err(err) = actor::load::config_from_repository(repo_details, &open_repository).await Err(err) = crate::load::config_from_repository(repo_details, &open_repository).await
); );
//then //then
tracing::debug!("Got: {err:?}"); tracing::debug!("Got: {err:?}");
assert!(matches!( assert!(matches!(
err, err,
actor::load::Error::File(git::file::Error::FileNotFound) crate::load::Error::File(git::file::Error::FileNotFound)
)); ));
Ok(()) Ok(())
} }
@ -33,11 +33,11 @@ async fn when_file_format_invalid_should_error() -> TestResult {
.return_once(move |_, _| Ok(contents)); .return_once(move |_, _| Ok(contents));
//when //when
let_assert!( let_assert!(
Err(err) = actor::load::config_from_repository(repo_details, &open_repository).await Err(err) = crate::load::config_from_repository(repo_details, &open_repository).await
); );
//then //then
tracing::debug!("Got: {err:?}"); tracing::debug!("Got: {err:?}");
assert!(matches!(err, actor::load::Error::Toml(_))); assert!(matches!(err, crate::load::Error::Toml(_)));
Ok(()) Ok(())
} }
@ -67,11 +67,11 @@ async fn when_main_branch_is_missing_should_error() -> TestResult {
.return_once(move || Ok(branches)); .return_once(move || Ok(branches));
//when //when
let_assert!( let_assert!(
Err(err) = actor::load::config_from_repository(repo_details, &open_repository).await Err(err) = crate::load::config_from_repository(repo_details, &open_repository).await
); );
//then //then
tracing::debug!("Got: {err:?}"); tracing::debug!("Got: {err:?}");
assert!(matches!(err, actor::load::Error::BranchNotFound(branch) if branch == main)); assert!(matches!(err, crate::load::Error::BranchNotFound(branch) if branch == main));
Ok(()) Ok(())
} }
@ -101,11 +101,11 @@ async fn when_next_branch_is_missing_should_error() -> TestResult {
.return_once(move || Ok(branches)); .return_once(move || Ok(branches));
//when //when
let_assert!( let_assert!(
Err(err) = actor::load::config_from_repository(repo_details, &open_repository).await Err(err) = crate::load::config_from_repository(repo_details, &open_repository).await
); );
//then //then
tracing::debug!("Got: {err:?}"); tracing::debug!("Got: {err:?}");
assert!(matches!(err, actor::load::Error::BranchNotFound(branch) if branch == next)); assert!(matches!(err, crate::load::Error::BranchNotFound(branch) if branch == next));
Ok(()) Ok(())
} }
@ -135,11 +135,11 @@ async fn when_dev_branch_is_missing_should_error() -> TestResult {
.return_once(move || Ok(branches)); .return_once(move || Ok(branches));
//when //when
let_assert!( let_assert!(
Err(err) = actor::load::config_from_repository(repo_details, &open_repository).await Err(err) = crate::load::config_from_repository(repo_details, &open_repository).await
); );
//then //then
tracing::debug!("Got: {err:?}"); tracing::debug!("Got: {err:?}");
assert!(matches!(err, actor::load::Error::BranchNotFound(branch) if branch == dev)); assert!(matches!(err, crate::load::Error::BranchNotFound(branch) if branch == dev));
Ok(()) Ok(())
} }
@ -170,7 +170,7 @@ async fn when_valid_file_should_return_repo_config() -> TestResult {
.return_once(move || Ok(branches)); .return_once(move || Ok(branches));
//when //when
let_assert!( let_assert!(
Ok(result) = actor::load::config_from_repository(repo_details, &open_repository).await Ok(result) = crate::load::config_from_repository(repo_details, &open_repository).await
); );
//then //then
tracing::debug!("Got: {result:?}"); tracing::debug!("Got: {result:?}");

View file

@ -2,11 +2,19 @@
use actix::prelude::*; use actix::prelude::*;
use crate::{ use crate::{
self as actor,
messages::{CloneRepo, MessageToken}, messages::{CloneRepo, MessageToken},
RepoActor, RepoActorLog, RepoActor, RepoActorLog,
}; };
use git_next_core::{ use git_next_core::{
git::{
self,
repository::{
factory::{MockRepositoryFactory, RepositoryFactory},
open::{MockOpenRepositoryLike, OpenRepositoryLike},
Direction,
},
Generation, MockForgeLike, RepoDetails,
},
message, message,
server::{InboundWebhook, WebhookUrl}, server::{InboundWebhook, WebhookUrl},
webhook::{self, forge_notification::Body}, webhook::{self, forge_notification::Body},
@ -14,15 +22,6 @@ use git_next_core::{
RegisteredWebhook, RemoteUrl, RepoAlias, RepoBranches, RepoConfig, RepoConfigSource, RegisteredWebhook, RemoteUrl, RepoAlias, RepoBranches, RepoConfig, RepoConfigSource,
ServerRepoConfig, StoragePathType, WebhookAuth, WebhookId, ServerRepoConfig, StoragePathType, WebhookAuth, WebhookId,
}; };
use git_next_git::{
self as git,
repository::{
factory::{MockRepositoryFactory, RepositoryFactory},
open::{MockOpenRepositoryLike, OpenRepositoryLike},
Direction,
},
Generation, MockForgeLike, RepoDetails,
};
use assert2::let_assert; use assert2::let_assert;
use mockall::predicate::eq; use mockall::predicate::eq;

View file

@ -8,14 +8,14 @@ mod handlers;
pub mod messages; pub mod messages;
use git_next_core::{ use git_next_core::{
git::{repository::factory::RepositoryFactory, Generation, RepoDetails},
server::{self, InboundWebhook, ServerConfig, ServerStorage}, server::{self, InboundWebhook, ServerConfig, ServerStorage},
ForgeAlias, ForgeConfig, GitDir, RepoAlias, ServerRepoConfig, StoragePathType, ForgeAlias, ForgeConfig, GitDir, RepoAlias, ServerRepoConfig, StoragePathType,
}; };
use git_next_git::{repository::factory::RepositoryFactory, Generation, RepoDetails};
use git_next_repo_actor::messages::NotifyUser; use git_next_repo_actor::messages::NotifyUser;
use git_next_repo_actor::{messages::CloneRepo, RepoActor}; use git_next_repo_actor::{messages::CloneRepo, RepoActor};
use git_next_webhook_actor::WebhookActor; use git_next_webhook_actor::WebhookActor;
use kxio::{fs::FileSystem, network::Network}; use kxio::{fs::FileSystem, network::Network};
use std::{ use std::{

View file

@ -2,7 +2,10 @@
use actix::prelude::*; use actix::prelude::*;
use crate::{tests::given, ReceiveServerConfig, ServerActor}; use crate::{tests::given, ReceiveServerConfig, ServerActor};
use git_next_core::server::{Http, InboundWebhook, Notification, ServerConfig, ServerStorage}; use git_next_core::{
git,
server::{Http, InboundWebhook, Notification, ServerConfig, ServerStorage},
};
use std::{ use std::{
collections::BTreeMap, collections::BTreeMap,
@ -15,7 +18,7 @@ async fn when_webhook_url_has_trailing_slash_should_not_send() {
// parameters // parameters
let fs = given::a_filesystem(); let fs = given::a_filesystem();
let net = given::a_network(); let net = given::a_network();
let repo = git_next_git::repository::factory::mock(); let repo = git::repository::factory::mock();
let duration = std::time::Duration::from_millis(1); let duration = std::time::Duration::from_millis(1);
// sut // sut

View file

@ -1,8 +1,8 @@
// //
use actix::prelude::*; use actix::prelude::*;
use git_next_core::git::RepositoryFactory;
use git_next_file_watcher_actor::{FileUpdated, FileWatcher}; use git_next_file_watcher_actor::{FileUpdated, FileWatcher};
use git_next_git::RepositoryFactory;
use git_next_server_actor::ServerActor; use git_next_server_actor::ServerActor;
use kxio::{fs::FileSystem, network::Network}; use kxio::{fs::FileSystem, network::Network};