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 --> git
forge --> core
forge --> git
forge --> forge_forgejo
forge --> forge_github
forge_forgejo --> core
forge_forgejo --> git
forge_github --> core
forge_github --> git
git --> core
repo_actor --> core
repo_actor --> git
repo_actor --> forge
server --> core
server --> git
server --> file_watcher_actor
server --> server_actor
server_actor --> core
server_actor --> git
server_actor --> forge
server_actor --> repo_actor
server_actor --> file_watcher_actor

View file

@ -4,6 +4,8 @@ mod init;
#[cfg(test)]
mod tests;
use git_next_core::git;
use std::path::PathBuf;
use clap::Parser;
@ -30,7 +32,7 @@ enum Server {
fn main() {
let fs = fs::new(PathBuf::default());
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();
match commands.command {

View file

@ -34,6 +34,7 @@ secrecy = { workspace = true }
# Git
gix = { workspace = true }
git-url-parse = { workspace = true }
async-trait = { workspace = true }
# Webhooks
ulid = { workspace = true }
@ -44,11 +45,17 @@ derive-with = { workspace = true }
thiserror = { workspace = true }
pike = { workspace = true }
# TOML parsing
serde_json = { workspace = true }
mockall = { workspace = true }
[dev-dependencies]
# Testing
assert2 = { workspace = true }
rand = { workspace = true }
test-log = { workspace = true }
pretty_assertions = { workspace = true }
[lints.clippy]
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 serde::Serialize;
@ -50,7 +50,7 @@ pub struct Histories {
}
pub mod log {
use git_next_core::BranchName;
use crate::BranchName;
pub type Result<T> = core::result::Result<T, Error>;

View file

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

View file

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

View file

@ -1,5 +1,6 @@
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.

View file

@ -1,9 +1,9 @@
//
use git_next_core::newtype;
use crate::newtype;
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.");
impl From<Commit> for GitRef {

View file

@ -1,7 +1,7 @@
//
use derive_more::{Constructor, Display};
use git_next_core::{Hostname, RepoPath};
use crate::{Hostname, RepoPath};
#[derive(Clone, Debug, PartialEq, Eq, Constructor, Display)]
#[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 git_next_core::BranchName;
use crate::{git, git::repository::open::OpenRepositoryLike, BranchName};
#[derive(Debug, PartialEq, Eq)]
pub enum Force {

View file

@ -1,9 +1,10 @@
//
use crate::{
repository::open::{oreal::RealOpenRepository, OpenRepositoryLike},
Generation, GitRemote,
};
use git_next_core::{
git::{
self,
repository::open::{oreal::RealOpenRepository, OpenRepositoryLike},
Generation, GitRemote,
},
pike, BranchName, ForgeAlias, ForgeConfig, ForgeDetails, GitDir, Hostname, RemoteUrl,
RepoAlias, RepoConfig, RepoPath, ServerRepoConfig, StoragePathType,
};
@ -86,7 +87,7 @@ impl RepoDetails {
}
#[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! {
self
|> Self::gitdir
@ -108,7 +109,7 @@ impl RepoDetails {
}
#[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 {
tracing::debug!("No remote url found to assert");
return Ok(());
@ -122,7 +123,7 @@ impl RepoDetails {
match self.gitdir.storage_path_type() {
StoragePathType::External => {
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),
expected: Box::new(expected),
});

View file

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

View file

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

View file

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

View file

@ -1,7 +1,8 @@
//
use crate::{self as git, repository::OpenRepositoryLike};
use git_next_core::{BranchName, Hostname, RemoteUrl, RepoPath};
use crate::{
git::{self, repository::OpenRepositoryLike},
BranchName, Hostname, RemoteUrl, RepoPath,
};
use derive_more::Constructor;
use gix::bstr::BStr;
@ -129,7 +130,7 @@ impl super::OpenRepositoryLike for RealOpenRepository {
&self,
branch_name: &BranchName,
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() {
true => 1,
false => 50,

View file

@ -1,11 +1,12 @@
//
use crate::{
self as git,
repository::open::{OpenRepositoryLike, RealOpenRepository},
git::{
self,
repository::open::{OpenRepositoryLike, RealOpenRepository},
},
BranchName, GitDir, RemoteUrl, RepoBranches,
};
use git_next_core::{BranchName, GitDir, RemoteUrl, RepoBranches};
use derive_more::{Constructor, Deref};
use std::{
@ -126,7 +127,7 @@ impl git::repository::OpenRepositoryLike for TestOpenRepository {
&self,
branch_name: &BranchName,
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)
}

View file

@ -8,6 +8,6 @@ fn should_fetch_from_repo() {
let_assert!(Ok(cwd) = std::env::current_dir());
let gitdir = GitDir::new(cwd.join("../.."), StoragePathType::External);
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());
}

View file

@ -9,6 +9,6 @@ fn should_find_default_push_remote() {
let url = repo_details.url();
given::a_bare_repo_with_url(fs.base(), url.expose_secret(), &fs);
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());
}

View file

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

View file

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

View file

@ -15,7 +15,7 @@ fn open_where_storage_external_auth_matches() -> TestResult {
let url = repo_details.url();
let url = url.expose_secret();
given::a_bare_repo_with_url(fs.base(), url, &fs);
let factory = crate::repository::factory::real();
let factory = git::repository::factory::real();
//when
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();
given::a_bare_repo_with_url(fs.base(), original_url, &fs);
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
let api_token = ApiToken::new(given::a_name().into());
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();
// create a bare repg with the auth from the forge_config
given::a_bare_repo_with_url(fs.base(), url, &fs);
let factory = crate::repository::factory::real();
let factory = git::repository::factory::real();
//when
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();
given::a_bare_repo_with_url(fs.base(), original_url, &fs);
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
let api_token = ApiToken::new(given::a_name().into());
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 git_next_core::{ApiToken, GitDir, StoragePathType};
use crate::{
git::{self, tests::given},
ApiToken, GitDir, StoragePathType,
};
use assert2::let_assert;

View file

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

View file

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

View file

@ -1,6 +1,8 @@
//
use crate::{self as git, repository::open::OpenRepositoryLike, RepoDetails, UserNotification};
use git_next_core::{BranchName, RepoConfig};
use crate::{
git::{self, repository::open::OpenRepositoryLike, RepoDetails, UserNotification},
BranchName, RepoConfig,
};
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
}

View file

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

View file

@ -1,18 +1,17 @@
//
use crate::{
self as git,
repository::{
open::otest::{OnFetch, OnPush},
Direction,
git::{
self,
repository::{
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;

View file

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

View file

@ -4,11 +4,10 @@ mod tests;
mod webhook;
use git::forge::commit::Status;
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 tracing::warn;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -6,11 +6,11 @@ mod commit;
mod webhook;
use crate as github;
use git::forge::commit::Status;
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;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,47 +4,9 @@ version = { workspace = true }
edition = { workspace = true }
license = { 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]
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]
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.
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 @@
//
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;
// moved to crates/core/src/git/

View file

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

View file

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

View file

@ -1,16 +1,16 @@
//
use actix::prelude::*;
use git_next_git::UserNotification;
use git_next_core::git::UserNotification;
use tracing::Instrument as _;
use crate::{self as actor};
impl Handler<actor::messages::LoadConfigFromRepo> for actor::RepoActor {
impl Handler<crate::messages::LoadConfigFromRepo> for crate::RepoActor {
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(
&mut self,
_msg: actor::messages::LoadConfigFromRepo,
_msg: crate::messages::LoadConfigFromRepo,
ctx: &mut Self::Context,
) -> Self::Result {
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 log = self.log.clone();
async move {
match actor::load::config_from_repository(repo_details, &*open_repository).await {
Ok(repo_config) => actor::do_send(
match crate::load::config_from_repository(repo_details, &*open_repository).await {
Ok(repo_config) => crate::do_send(
addr,
actor::messages::ReceiveRepoConfig::new(repo_config),
crate::messages::ReceiveRepoConfig::new(repo_config),
log.as_ref(),
),
Err(err) => actor::notify_user(
Err(err) => crate::notify_user(
notify_user_recipient.as_ref(),
UserNotification::RepoConfigLoadFailure {
forge_alias,

View file

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

View file

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

View file

@ -1,26 +1,27 @@
//
use actix::prelude::*;
use derive_more::Deref as _;
use tracing::Instrument as _;
use crate::{self as actor, messages::MessageToken};
use git_next_git as git;
use crate::messages::MessageToken;
use git_next_core::git;
impl Handler<actor::messages::ValidateRepo> for actor::RepoActor {
impl Handler<crate::messages::ValidateRepo> for crate::RepoActor {
type Result = ();
#[tracing::instrument(name = "RepoActor::ValidateRepo", skip_all, fields(repo = %self.repo_details, token = %msg.deref()))]
fn handle(
&mut self,
msg: actor::messages::ValidateRepo,
msg: crate::messages::ValidateRepo,
ctx: &mut Self::Context,
) -> 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
match self.token_status(msg.unwrap()) {
TokenStatus::Current => {} // do nothing
TokenStatus::Expired => {
actor::logger(
crate::logger(
self.log.as_ref(),
format!("discarded: old message token: {}", self.message_token),
);
@ -28,28 +29,28 @@ impl Handler<actor::messages::ValidateRepo> for actor::RepoActor {
}
TokenStatus::New(message_token) => {
self.message_token = message_token;
actor::logger(
crate::logger(
self.log.as_ref(),
format!("new message token: {}", self.message_token),
);
}
}
actor::logger(
crate::logger(
self.log.as_ref(),
format!("accepted token: {}", self.message_token),
);
// Repository positions
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;
};
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 {
actor::logger(self.log.as_ref(), "no repo config");
crate::logger(self.log.as_ref(), "no repo config");
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(
&**open_repository,
@ -64,15 +65,15 @@ impl Handler<actor::messages::ValidateRepo> for actor::RepoActor {
}) => {
tracing::debug!(%main, %next, %dev, "positions");
if next != main {
actor::do_send(
crate::do_send(
ctx.address(),
actor::messages::CheckCIStatus::new(next),
crate::messages::CheckCIStatus::new(next),
self.log.as_ref(),
);
} else if next != dev {
actor::do_send(
crate::do_send(
ctx.address(),
actor::messages::AdvanceNext::new((next, dev_commit_history)),
crate::messages::AdvanceNext::new((next, dev_commit_history)),
self.log.as_ref(),
)
} else {
@ -80,19 +81,19 @@ impl Handler<actor::messages::ValidateRepo> for actor::RepoActor {
}
}
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 message_token = self.message_token;
let sleep_duration = self.sleep_duration;
let log = self.log.clone();
async move {
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;
actor::logger(log.as_ref(), "after sleep");
actor::do_send(
crate::logger(log.as_ref(), "after sleep");
crate::do_send(
addr,
actor::messages::ValidateRepo::new(message_token),
crate::messages::ValidateRepo::new(message_token),
log.as_ref(),
);
}
@ -101,14 +102,14 @@ impl Handler<actor::messages::ValidateRepo> for actor::RepoActor {
.wait(ctx);
}
Err(git::validation::positions::Error::UserIntervention(user_notification)) => {
actor::notify_user(
crate::notify_user(
self.notify_user_recipient.as_ref(),
user_notification,
self.log.as_ref(),
)
}
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,
New(MessageToken),
}
impl actor::RepoActor {
impl crate::RepoActor {
fn token_status(&self, new: MessageToken) -> TokenStatus {
let current = &self.message_token;
if &new > current {

View file

@ -1,22 +1,22 @@
//
use actix::prelude::*;
use crate::{self as actor, messages::WebhookNotification, RepoActorLog};
use crate::{messages::WebhookNotification, RepoActorLog};
use git_next_core::{
git::{self, Commit, ForgeLike},
webhook::{push::Branch, Push},
BranchName, WebhookAuth,
};
use git_next_git::{self as git, Commit, ForgeLike};
use tracing::{info, warn};
impl Handler<WebhookNotification> for actor::RepoActor {
impl Handler<WebhookNotification> for crate::RepoActor {
type Result = ();
#[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 {
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");
return;
};
@ -33,13 +33,13 @@ impl Handler<WebhookNotification> for actor::RepoActor {
let body = msg.body();
match self.forge.parse_webhook_body(body) {
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'");
return;
}
Ok(push) => match push.branch(config.branches()) {
None => {
actor::logger(self.log.as_ref(), "unknown branch");
crate::logger(self.log.as_ref(), "unknown branch");
warn!(
?push,
"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,
"New commit"
);
actor::do_send(
crate::do_send(
ctx.address(),
actor::messages::ValidateRepo::new(message_token),
crate::messages::ValidateRepo::new(message_token),
self.log.as_ref(),
);
}
@ -104,13 +104,13 @@ fn validate_notification(
log: Option<&RepoActorLog>,
) -> Result<(), ()> {
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");
return Err(());
};
if !forge.is_message_authorised(msg, expected_authorization) {
actor::logger(log, "message authorisation is invalid");
crate::logger(log, "message authorisation is invalid");
warn!(
"Invalid authorization - expected {}",
expected_authorization
@ -118,7 +118,7 @@ fn validate_notification(
return Err(());
}
if forge.should_ignore_message(msg) {
actor::logger(log, "forge sent ignorable message");
crate::logger(log, "forge sent ignorable message");
return Err(());
}
Ok(())
@ -130,10 +130,10 @@ fn handle_push(
last_commit: &mut Option<Commit>,
log: Option<&RepoActorLog>,
) -> Result<(), ()> {
actor::logger(log, "message is for dev branch");
crate::logger(log, "message is for dev branch");
let commit = git::Commit::from(push);
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!(
%branch ,
%commit,

View file

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

View file

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

View file

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

View file

@ -1,8 +1,9 @@
use derive_more::Deref as _;
use git_next_git::UserNotification;
use serde_json::json;
use crate::messages::NotifyUser;
use git_next_core::git::UserNotification;
use serde_json::json;
impl NotifyUser {
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));
let_assert!(
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!(
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::push_ok(&mut open_repository);
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
let message_token = given::a_message_token();
let_assert!(
Err(err) = actor::branch::advance_next(
Err(err) = crate::branch::advance_next(
&next,
dev_commit_history,
repo_details,
@ -24,7 +24,7 @@ mod when_at_dev {
)
);
tracing::debug!("Got: {err}");
assert!(matches!(err, actor::branch::Error::NextAtDev));
assert!(matches!(err, crate::branch::Error::NextAtDev));
Ok(())
}
}
@ -47,7 +47,7 @@ mod can_advance {
// no on_push defined - so any call to push will cause an error
let message_token = given::a_message_token();
let_assert!(
Err(err) = actor::branch::advance_next(
Err(err) = crate::branch::advance_next(
&next,
dev_commit_history,
repo_details,
@ -57,7 +57,7 @@ mod can_advance {
)
);
tracing::debug!("Got: {err}");
assert!(matches!(err, actor::branch::Error::IsWorkInProgress));
assert!(matches!(err, crate::branch::Error::IsWorkInProgress));
Ok(())
}
}
@ -77,7 +77,7 @@ mod can_advance {
// no on_push defined - so any call to push will cause an error
let message_token = given::a_message_token();
let_assert!(
Err(err) = actor::branch::advance_next(
Err(err) = crate::branch::advance_next(
&next,
dev_commit_history,
repo_details,
@ -89,7 +89,7 @@ mod can_advance {
tracing::debug!("Got: {err}");
assert!(matches!(
err,
actor::branch::Error::InvalidCommitMessage{reason}
crate::branch::Error::InvalidCommitMessage{reason}
if reason == "Missing type in the commit summary, expected `type: description`"
));
Ok(())
@ -116,7 +116,7 @@ mod can_advance {
expect::push(&mut open_repository, Err(git::push::Error::Lock));
let message_token = given::a_message_token();
let_assert!(
Err(err) = actor::branch::advance_next(
Err(err) = crate::branch::advance_next(
&next,
dev_commit_history,
repo_details,
@ -128,7 +128,7 @@ mod can_advance {
tracing::debug!("Got: {err:?}");
assert!(matches!(
err,
actor::branch::Error::Push(git::push::Error::Lock)
crate::branch::Error::Push(git::push::Error::Lock)
));
Ok(())
}
@ -150,7 +150,7 @@ mod can_advance {
expect::push_ok(&mut open_repository);
let message_token = given::a_message_token();
let_assert!(
Ok(mt) = actor::branch::advance_next(
Ok(mt) = crate::branch::advance_next(
&next,
dev_commit_history,
repo_details,

View file

@ -15,7 +15,7 @@ async fn test_find_next_commit_on_dev() {
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");
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -15,7 +15,7 @@ async fn should_store_webhook_details() -> TestResult {
repo_details,
given::a_forge(),
);
addr.send(actor::messages::WebhookRegistered::new((
addr.send(crate::messages::WebhookRegistered::new((
webhook_id.clone(),
webhook_auth.clone(),
)))
@ -43,7 +43,7 @@ async fn should_send_validate_repo_message() -> TestResult {
repo_details,
given::a_forge(),
);
addr.send(actor::messages::WebhookRegistered::new((
addr.send(crate::messages::WebhookRegistered::new((
webhook_id.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));
//when
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
tracing::debug!("Got: {err:?}");
assert!(matches!(
err,
actor::load::Error::File(git::file::Error::FileNotFound)
crate::load::Error::File(git::file::Error::FileNotFound)
));
Ok(())
}
@ -33,11 +33,11 @@ async fn when_file_format_invalid_should_error() -> TestResult {
.return_once(move |_, _| Ok(contents));
//when
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
tracing::debug!("Got: {err:?}");
assert!(matches!(err, actor::load::Error::Toml(_)));
assert!(matches!(err, crate::load::Error::Toml(_)));
Ok(())
}
@ -67,11 +67,11 @@ async fn when_main_branch_is_missing_should_error() -> TestResult {
.return_once(move || Ok(branches));
//when
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
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(())
}
@ -101,11 +101,11 @@ async fn when_next_branch_is_missing_should_error() -> TestResult {
.return_once(move || Ok(branches));
//when
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
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(())
}
@ -135,11 +135,11 @@ async fn when_dev_branch_is_missing_should_error() -> TestResult {
.return_once(move || Ok(branches));
//when
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
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(())
}
@ -170,7 +170,7 @@ async fn when_valid_file_should_return_repo_config() -> TestResult {
.return_once(move || Ok(branches));
//when
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
tracing::debug!("Got: {result:?}");

View file

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

View file

@ -8,14 +8,14 @@ mod handlers;
pub mod messages;
use git_next_core::{
git::{repository::factory::RepositoryFactory, Generation, RepoDetails},
server::{self, InboundWebhook, ServerConfig, ServerStorage},
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::CloneRepo, RepoActor};
use git_next_webhook_actor::WebhookActor;
use kxio::{fs::FileSystem, network::Network};
use std::{

View file

@ -2,7 +2,10 @@
use actix::prelude::*;
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::{
collections::BTreeMap,
@ -15,7 +18,7 @@ async fn when_webhook_url_has_trailing_slash_should_not_send() {
// parameters
let fs = given::a_filesystem();
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);
// sut

View file

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