refactor: pass RepoDetails by reference

This commit is contained in:
Paul Campbell 2024-04-11 14:27:59 +01:00
parent ed1ab6faa5
commit d2d49f353c
2 changed files with 9 additions and 9 deletions

View file

@ -18,7 +18,7 @@ pub async fn check_next(
// get the status - pass, fail, pending (all others map to fail, e.g. error)
let status = match repo_details.forge.forge_type {
ForgeType::ForgeJo => {
forge::forgejo::get_commit_status(next.clone(), repo_details, net).await
forge::forgejo::get_commit_status(next.clone(), &repo_details, net).await
}
};
info!(?status, "Checking next branch status");
@ -31,9 +31,8 @@ pub async fn check_next(
} // TODO: (#22) wait and try again OR can webhook tell us when it's done, in
// which case we can do nothing here and wait for the webhook to trigger
Status::Fail => {
warn!("Check have failed");
} // TODO: (#21) reset next and wait for dev to be updated and this
// commit removed from the commit history before trying again
warn!("Checks have failed");
}
}
}

View file

@ -2,6 +2,7 @@ use kxio::network;
use terrors::OneOf;
use tracing::{error, info, warn};
use crate::server;
use crate::server::{actors::repo::status::Status, config::BranchName, forge};
use super::CommitHistories;
@ -9,8 +10,8 @@ use super::CommitHistories;
pub mod config;
pub async fn get_commit_histories(
repo_details: &crate::server::config::RepoDetails,
config: &crate::server::config::RepoConfig,
repo_details: &server::config::RepoDetails,
config: &server::config::RepoConfig,
net: &kxio::network::Network,
) -> Result<CommitHistories, OneOf<(network::NetworkError,)>> {
let main = (get_commit_history(repo_details, &config.branches().main(), None, net).await)?;
@ -30,9 +31,9 @@ pub async fn get_commit_histories(
#[tracing::instrument(fields(%branch_name),skip_all)]
async fn get_commit_history(
repo_details: &crate::server::config::RepoDetails,
repo_details: &server::config::RepoDetails,
branch_name: &BranchName,
find_commit: Option<&forge::Commit>, // INFO: (#23) if [None] then get only one commit, if [Some] then get all commits up to this one or return an error
find_commit: Option<&forge::Commit>,
net: &kxio::network::Network,
) -> Result<Vec<forge::Commit>, OneOf<(network::NetworkError,)>> {
let hostname = &repo_details.forge.hostname;
@ -94,7 +95,7 @@ struct Commit {
pub async fn get_commit_status(
next: forge::Commit,
repo_details: crate::server::config::RepoDetails,
repo_details: &crate::server::config::RepoDetails,
net: network::Network,
) -> Status {
let hostname = &repo_details.forge.hostname;