mirror of
https://github.com/msfjarvis/gitice
synced 2025-08-14 22:07:00 +05:30
fix: use tracing consistently
This commit is contained in:
parent
61d0c766a1
commit
a728a353d6
1 changed files with 7 additions and 7 deletions
14
src/git.rs
14
src/git.rs
|
@ -1,4 +1,5 @@
|
||||||
use crate::model::PersistableRepo;
|
use crate::model::PersistableRepo;
|
||||||
|
use anyhow::Context;
|
||||||
use gix::{sec::trust::DefaultForLevel, Repository, ThreadSafeRepository};
|
use gix::{sec::trust::DefaultForLevel, Repository, ThreadSafeRepository};
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
|
@ -72,7 +73,7 @@ pub(crate) fn freeze_repos(dir: &str) -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fs::write("gitice.lock", toml::to_string(&repos)?).expect("could not write to lockfile!");
|
fs::write("gitice.lock", toml::to_string(&repos)?).context("could not write to lockfile!")?;
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
"Successfully generated lockfile with {} repos",
|
"Successfully generated lockfile with {} repos",
|
||||||
&repos.len()
|
&repos.len()
|
||||||
|
@ -81,12 +82,11 @@ pub(crate) fn freeze_repos(dir: &str) -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn thaw_repos(dir: &str, lockfile: &str) -> anyhow::Result<()> {
|
pub(crate) fn thaw_repos(dir: &str, lockfile: &str) -> anyhow::Result<()> {
|
||||||
let lockfile = fs::read_to_string(lockfile)
|
let lockfile = fs::read_to_string(lockfile).context(format!("Failed to read {lockfile}"))?;
|
||||||
.unwrap_or_else(|_| panic!("unable to read lockfile from {}", lockfile));
|
|
||||||
let repos: HashMap<String, PersistableRepo> = toml::from_str(&lockfile)?;
|
let repos: HashMap<String, PersistableRepo> = toml::from_str(&lockfile)?;
|
||||||
|
|
||||||
for (name, repo) in repos {
|
for (name, repo) in repos {
|
||||||
println!("Cloning {} from {}", &name, &repo.remote_url);
|
tracing::info!("Cloning {name} from {}", &repo.remote_url);
|
||||||
let output = Command::new("git")
|
let output = Command::new("git")
|
||||||
.args([
|
.args([
|
||||||
"clone",
|
"clone",
|
||||||
|
@ -94,12 +94,12 @@ pub(crate) fn thaw_repos(dir: &str, lockfile: &str) -> anyhow::Result<()> {
|
||||||
PathBuf::from(&dir).join(&name).to_str().unwrap(),
|
PathBuf::from(&dir).join(&name).to_str().unwrap(),
|
||||||
])
|
])
|
||||||
.output()
|
.output()
|
||||||
.expect("Failed to run `git clone`. Perhaps git is not installed?");
|
.context("Failed to run `git clone`. Perhaps git is not installed?")?;
|
||||||
|
|
||||||
if output.status.success() {
|
if output.status.success() {
|
||||||
println!("Thawed {name} successfully.");
|
tracing::info!("Thawed {} successfully.", name);
|
||||||
} else {
|
} else {
|
||||||
println!("{}", std::str::from_utf8(&output.stderr)?);
|
tracing::error!("{}", std::str::from_utf8(&output.stderr)?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue