Log fetched refs
This commit is contained in:
parent
b9a5cddc42
commit
96e5881665
3 changed files with 13 additions and 7 deletions
|
|
@ -102,7 +102,7 @@ pub fn fetch_head(path: &Path, url: &str) -> Result<(), Error> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn fetch(path: &Path, url: &str, refspecs: &[String]) -> Result<(), Error> {
|
||||
pub fn fetch(path: &Path, url: &str, refspecs: &[String]) -> Result<Output, Error> {
|
||||
let mut command = Command::new("git");
|
||||
command
|
||||
.arg("-C")
|
||||
|
|
@ -114,6 +114,5 @@ pub fn fetch(path: &Path, url: &str, refspecs: &[String]) -> Result<(), Error> {
|
|||
for refspec in refspecs {
|
||||
command.arg(refspec);
|
||||
}
|
||||
run(command)?;
|
||||
Ok(())
|
||||
run(command)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,9 @@ fn open_repo(
|
|||
git::fetch_head(path, url)?;
|
||||
|
||||
info!("Fetching refs for the first time (this may take a while)");
|
||||
git::fetch(path, url, refspecs)?;
|
||||
let output = git::fetch(path, url, refspecs)?;
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
info!("Fetched refs:\n{}", stderr.trim_end());
|
||||
|
||||
Ok(ThreadSafeRepository::open(path)?)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,17 +1,22 @@
|
|||
//! Update repo refs using the `git` binary.
|
||||
|
||||
use log::{info, warn};
|
||||
use log::{debug, info, warn};
|
||||
|
||||
use crate::{config::ServerConfig, git, server::Repo, somehow};
|
||||
|
||||
async fn inner(repo: Repo, url: &'static str, refspecs: &'static [String]) -> somehow::Result<()> {
|
||||
let output =
|
||||
tokio::task::spawn_blocking(move || git::fetch(repo.0.path(), url, refspecs)).await??;
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
if !stderr.is_empty() {
|
||||
info!("Fetched refs:\n{}", stderr.trim_end());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) async fn update(config: &'static ServerConfig, repo: Repo) {
|
||||
if let Some(url) = &config.repo_fetch_url {
|
||||
info!("Fetching refs from {url}");
|
||||
debug!("Fetching refs from {url}");
|
||||
if let Err(e) = inner(repo, url, &config.repo_fetch_refspecs).await {
|
||||
warn!("Error fetching refs:\n{e:?}");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue