diff --git a/src/server/git/mod.rs b/src/server/git/mod.rs new file mode 100644 index 0000000..ce8a5bb --- /dev/null +++ b/src/server/git/mod.rs @@ -0,0 +1,3 @@ +pub mod reset; + +pub use reset::reset; diff --git a/src/server/gitforge/forgejo/branch/reset.rs b/src/server/git/reset.rs similarity index 96% rename from src/server/gitforge/forgejo/branch/reset.rs rename to src/server/git/reset.rs index f426c31..4fe6a89 100644 --- a/src/server/gitforge/forgejo/branch/reset.rs +++ b/src/server/git/reset.rs @@ -36,7 +36,6 @@ pub fn reset( git_dir: Some(gitdir.to_path_buf()), ..Default::default() }; - // info!(?ctx, command = command.expose_secret(), "prepare"); match gix::command::prepare(command.expose_secret()) .with_context(ctx) .with_shell_allow_argument_splitting() diff --git a/src/server/gitforge/forgejo/branch/fetch.rs b/src/server/gitforge/forgejo/branch/fetch.rs index 19bd6a3..6d8c01c 100644 --- a/src/server/gitforge/forgejo/branch/fetch.rs +++ b/src/server/gitforge/forgejo/branch/fetch.rs @@ -37,36 +37,4 @@ pub fn fetch(repo_details: &RepoDetails) -> Result<(), Error> { info!("fetched"); Ok(()) - - // INFO: never log the command as it contains the API token within the 'origin' - // let command: secrecy::Secret = format!( - // "/usr/bin/git push {} {to_commit}:{branch_name} {force}", - // origin.expose_secret() - // ) - // .into(); - // info!("Resetting {branch_name} to {to_commit}"); - // let ctx = gix::diff::command::Context { - // git_dir: Some(repo_details.gitdir.deref().clone()), - // ..Default::default() - // }; - // // info!(?ctx, command = command.expose_secret(), "prepare"); - // match gix::command::prepare(command.expose_secret()) - // .with_context(ctx) - // .with_shell_allow_argument_splitting() - // // .stdout(std::process::Stdio::null()) - // // .stderr(std::process::Stdio::null()) - // .spawn() - // { - // Ok(mut child) => match child.wait() { - // Ok(_) => Ok(()), - // Err(err) => { - // warn!(?err, "Failed (wait)"); - // Err(()) - // } - // }, - // Err(err) => { - // warn!(?err, "Failed (spawn)"); - // Err(()) - // } - // } } diff --git a/src/server/gitforge/forgejo/branch/mod.rs b/src/server/gitforge/forgejo/branch/mod.rs index 6b9051f..d756722 100644 --- a/src/server/gitforge/forgejo/branch/mod.rs +++ b/src/server/gitforge/forgejo/branch/mod.rs @@ -1,10 +1,9 @@ pub mod fetch; mod get_all; -mod reset; mod validate_positions; pub use fetch::fetch; pub use get_all::get_all; -pub use reset::reset; + pub use validate_positions::validate_positions; pub use validate_positions::ValidatedPositions; diff --git a/src/server/gitforge/forgejo/mod.rs b/src/server/gitforge/forgejo/mod.rs index c8d683a..cacfcbf 100644 --- a/src/server/gitforge/forgejo/mod.rs +++ b/src/server/gitforge/forgejo/mod.rs @@ -12,6 +12,7 @@ use tracing::{error, info, warn}; use crate::server::{ actors::repo::{RepoActor, StartMonitoring, ValidateRepo}, config::{BranchName, GitDir, RepoConfig, RepoDetails}, + git, gitforge::{self, forgejo::branch::ValidatedPositions, RepoCloneError}, types::{GitRef, MessageToken}, }; @@ -80,7 +81,7 @@ impl super::ForgeLike for ForgeJoEnv { force: gitforge::Force, ) -> gitforge::BranchResetResult { branch::fetch(&self.repo_details)?; - branch::reset(&self.repo_details, branch_name, to_commit, force) + git::reset(&self.repo_details, branch_name, to_commit, force) } async fn commit_status(&self, commit: &gitforge::Commit) -> gitforge::CommitStatus { diff --git a/src/server/mod.rs b/src/server/mod.rs index 20b0e23..1208f62 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -1,5 +1,6 @@ mod actors; mod config; +pub mod git; pub mod gitforge; pub mod types;