gitdataai/libs/git/hook/sync/gc.rs
ZhenYi 0c1a9ddf98 refactor(git): migrate libs/git from slog to tracing
- Remove all use slog::* imports and log: slog::Logger fields
- ssh/handle.rs: replace slog macro chains with tracing::{info!, warn!,
  error!, debug!}; remove log field from GitSshHandle
- ssh/authz.rs, ssh/mod.rs, ssh/server.rs: remove slog Logger fields
- http/: auth.rs, handler.rs, mod.rs, routes.rs: remove slog usage
- hook/: pool worker, sync modules, webhook_dispatch.rs: remove slog
2026-04-21 22:29:26 +08:00

31 lines
1.0 KiB
Rust

use crate::GitError;
use crate::hook::sync::HookMetaDataSync;
use std::process::Command;
impl HookMetaDataSync {
pub async fn run_gc(&self) -> Result<(), GitError> {
let storage_path = self.repo.storage_path.clone();
tokio::task::spawn_blocking(move || {
let status = Command::new("git")
.arg("-C")
.arg(&storage_path)
.arg("gc")
.arg("--auto")
.arg("--quiet")
.status()
.map_err(|e| GitError::IoError(format!("git gc failed: {}", e)))?;
if !status.success() {
// git gc --auto exits non-zero when there's nothing to collect,
// or when another gc is already running — both are benign.
tracing::warn!(code = ?status.code(), "git gc exited with non-zero status");
}
Ok::<(), GitError>(())
})
.await
.map_err(|e| GitError::Internal(format!("spawn_blocking join error: {}", e)))?
}
}