diff --git a/src/server/gitforge/forgejo/branch/fetch.rs b/src/server/gitforge/forgejo/branch/fetch.rs index fd060ed..19bd6a3 100644 --- a/src/server/gitforge/forgejo/branch/fetch.rs +++ b/src/server/gitforge/forgejo/branch/fetch.rs @@ -1,6 +1,6 @@ use std::ops::Deref; -use tracing::info; +use tracing::{debug, info}; use crate::server::config::RepoDetails; @@ -13,17 +13,17 @@ pub enum Error { } impl std::error::Error for Error {} -#[tracing::instrument] +#[tracing::instrument(skip_all, fields(repo = %repo_details))] pub fn fetch(repo_details: &RepoDetails) -> Result<(), Error> { // INFO: gitdir validate tests that the default fetch remote matches the configured remote let repository = gix::ThreadSafeRepository::open(repo_details.gitdir.deref()) .map_err(Box::new)? .to_thread_local(); - info!(?repository, "opened repo"); + debug!(?repository, "opened repo"); let Some(remote) = repository.find_default_remote(gix::remote::Direction::Fetch) else { return Err(Error::NoFetchRemoteFound); }; - info!(?remote, "fetch remote"); + debug!(?remote, "fetch remote"); remote .map_err(|e| Error::Fetch(e.to_string()))? diff --git a/src/server/gitforge/forgejo/branch/reset.rs b/src/server/gitforge/forgejo/branch/reset.rs index caef4b9..f426c31 100644 --- a/src/server/gitforge/forgejo/branch/reset.rs +++ b/src/server/gitforge/forgejo/branch/reset.rs @@ -10,7 +10,7 @@ use crate::server::{ }; // TODO: (#72) reimplement using `gix` -#[tracing::instrument] +#[tracing::instrument(skip_all, fields(branch = %branch_name, to = %to_commit, force = %force))] pub fn reset( repo_details: &RepoDetails, branch_name: BranchName, @@ -32,7 +32,6 @@ pub fn reset( origin.expose_secret() ) .into(); - info!("Resetting {branch_name} to {to_commit}"); let ctx = gix::diff::command::Context { git_dir: Some(gitdir.to_path_buf()), ..Default::default() @@ -41,12 +40,15 @@ pub fn reset( 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()) + .stdout(std::process::Stdio::null()) + .stderr(std::process::Stdio::null()) .spawn() { Ok(mut child) => match child.wait() { - Ok(_) => Ok(()), + Ok(_) => { + info!("Branch updated"); + Ok(()) + } Err(err) => { warn!(?err, "Failed (wait)"); Err(BranchResetError::Push) diff --git a/src/server/gitforge/types.rs b/src/server/gitforge/types.rs index 5c637c2..407a020 100644 --- a/src/server/gitforge/types.rs +++ b/src/server/gitforge/types.rs @@ -15,7 +15,10 @@ pub enum Force { } impl std::fmt::Display for Force { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{:?}", self) + match self { + Self::No => write!(f, "fast-foward"), + Self::From(from) => write!(f, "force-if-from:{}", from), + } } }