refactor(server): collapse type module into gitforge module
This commit is contained in:
parent
341dc97a51
commit
df8ebc6af7
9 changed files with 24 additions and 27 deletions
|
@ -20,7 +20,7 @@ pub async fn advance_next(
|
|||
forge: gitforge::Forge,
|
||||
repository: git::OpenRepository,
|
||||
addr: Addr<super::RepoActor>,
|
||||
message_token: super::MessageToken,
|
||||
message_token: gitforge::MessageToken,
|
||||
) {
|
||||
let next_commit = find_next_commit_on_dev(next, dev_commit_history);
|
||||
let Some(commit) = next_commit else {
|
||||
|
@ -84,7 +84,7 @@ pub async fn advance_main(
|
|||
forge: gitforge::Forge,
|
||||
repository: git::OpenRepository,
|
||||
addr: Addr<RepoActor>,
|
||||
message_token: super::MessageToken,
|
||||
message_token: gitforge::MessageToken,
|
||||
) {
|
||||
info!("Advancing main to next");
|
||||
if let Err(err) = forge.branch_reset(
|
||||
|
|
|
@ -13,7 +13,7 @@ use git_next_git::{self as git, Generation, RepoDetails};
|
|||
use kxio::network::Network;
|
||||
use tracing::{debug, info, warn, Instrument};
|
||||
|
||||
use crate::{actors::repo::webhook::WebhookAuth, config::Webhook, gitforge, types::MessageToken};
|
||||
use crate::{actors::repo::webhook::WebhookAuth, config::Webhook, gitforge};
|
||||
|
||||
use self::webhook::WebhookId;
|
||||
|
||||
|
@ -21,7 +21,7 @@ use self::webhook::WebhookId;
|
|||
#[display("{}:{}:{}", generation, details.forge.forge_name(), details.repo_alias)]
|
||||
pub struct RepoActor {
|
||||
generation: Generation,
|
||||
message_token: MessageToken,
|
||||
message_token: gitforge::MessageToken,
|
||||
details: RepoDetails,
|
||||
webhook: Webhook,
|
||||
webhook_id: Option<WebhookId>, // INFO: if [None] then no webhook is configured
|
||||
|
@ -49,7 +49,7 @@ impl RepoActor {
|
|||
debug!(?forge, "new");
|
||||
Self {
|
||||
generation,
|
||||
message_token: MessageToken::new(),
|
||||
message_token: gitforge::MessageToken::new(),
|
||||
details,
|
||||
webhook,
|
||||
webhook_id: None,
|
||||
|
@ -144,7 +144,7 @@ impl Handler<LoadedConfig> for RepoActor {
|
|||
#[derive(derive_more::Constructor, Message)]
|
||||
#[rtype(result = "()")]
|
||||
pub struct ValidateRepo {
|
||||
message_token: MessageToken,
|
||||
message_token: gitforge::MessageToken,
|
||||
}
|
||||
impl Handler<ValidateRepo> for RepoActor {
|
||||
type Result = ();
|
||||
|
|
|
@ -2,7 +2,7 @@ use actix::prelude::*;
|
|||
use git_next_git as git;
|
||||
use tracing::{info, warn};
|
||||
|
||||
use crate::{actors::repo::ValidateRepo, gitforge, types::MessageToken};
|
||||
use crate::{actors::repo::ValidateRepo, gitforge};
|
||||
|
||||
use super::AdvanceMainTo;
|
||||
|
||||
|
@ -10,7 +10,7 @@ pub async fn check_next(
|
|||
next: git::Commit,
|
||||
addr: Addr<super::RepoActor>,
|
||||
forge: gitforge::Forge,
|
||||
message_token: MessageToken,
|
||||
message_token: gitforge::MessageToken,
|
||||
) {
|
||||
// get the status - pass, fail, pending (all others map to fail, e.g. error)
|
||||
let status = forge.commit_status(&next).await;
|
||||
|
|
|
@ -13,8 +13,7 @@ use tracing::{error, info, warn};
|
|||
|
||||
use crate::{
|
||||
actors::repo::{RepoActor, StartMonitoring, ValidateRepo},
|
||||
gitforge::{self, forgejo::branch::ValidatedPositions},
|
||||
types::MessageToken,
|
||||
gitforge,
|
||||
};
|
||||
|
||||
struct ForgeJo;
|
||||
|
@ -56,10 +55,10 @@ impl super::ForgeLike for ForgeJoEnv {
|
|||
repository: git::OpenRepository,
|
||||
repo_config: RepoConfig,
|
||||
addr: Addr<RepoActor>,
|
||||
message_token: MessageToken,
|
||||
message_token: gitforge::MessageToken,
|
||||
) {
|
||||
match branch::validate_positions(self, &repository, repo_config).await {
|
||||
Ok(ValidatedPositions {
|
||||
Ok(branch::ValidatedPositions {
|
||||
main,
|
||||
next,
|
||||
dev,
|
||||
|
|
|
@ -2,7 +2,7 @@ use git::OpenRepository;
|
|||
use git_next_config::{BranchName, GitDir, RepoConfig};
|
||||
use git_next_git::{self as git, GitRef};
|
||||
|
||||
use crate::{actors::repo::RepoActor, gitforge, types::MessageToken};
|
||||
use crate::{actors::repo::RepoActor, gitforge};
|
||||
|
||||
struct MockForge;
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -35,7 +35,7 @@ impl super::ForgeLike for MockForgeEnv {
|
|||
_repository: OpenRepository,
|
||||
_repo_config: RepoConfig,
|
||||
_addr: actix::prelude::Addr<RepoActor>,
|
||||
_message_token: MessageToken,
|
||||
_message_token: gitforge::MessageToken,
|
||||
) {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@ pub use types::*;
|
|||
mod errors;
|
||||
pub use errors::*;
|
||||
|
||||
use crate::types::MessageToken;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait ForgeLike {
|
||||
fn name(&self) -> String;
|
||||
|
|
|
@ -13,3 +13,14 @@ pub struct CommitHistories {
|
|||
pub next: Vec<git::Commit>,
|
||||
pub dev: Vec<git::Commit>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, derive_more::Display)]
|
||||
pub struct MessageToken(u32);
|
||||
impl MessageToken {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
pub const fn next(&self) -> Self {
|
||||
Self(self.0 + 1)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
mod actors;
|
||||
mod config;
|
||||
pub mod gitforge;
|
||||
pub mod types;
|
||||
|
||||
use actix::prelude::*;
|
||||
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, derive_more::Display)]
|
||||
pub struct MessageToken(u32);
|
||||
impl MessageToken {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
pub const fn next(&self) -> Self {
|
||||
Self(self.0 + 1)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue