Skip to content

Commit

Permalink
style: format
Browse files Browse the repository at this point in the history
  • Loading branch information
bezhermoso committed Jan 12, 2025
1 parent 9d5597b commit 91f5701
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/operations/update.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
use crate::constants::{REPO_DIR, SCHEMES_REPO_NAME, SCHEMES_REPO_URL, SCHEMES_REPO_REVISION};
use crate::constants::{REPO_DIR, SCHEMES_REPO_NAME, SCHEMES_REPO_REVISION, SCHEMES_REPO_URL};
use crate::utils::{git_diff, git_update};
use crate::{config::Config, constants::REPO_NAME};
use anyhow::{Context, Result};
use std::path::Path;

fn update_item(item_name: &str, item_url: &str, item_path: &Path, revision: Option<&str>, is_quiet: bool) -> Result<()> {
fn update_item(
item_name: &str,
item_url: &str,
item_path: &Path,
revision: Option<&str>,
is_quiet: bool,
) -> Result<()> {
if item_path.is_dir() {
let is_diff = git_diff(item_path)?;

if !is_diff {
git_update(item_path, item_url, revision)
.with_context(|| format!("Error updating {} to {}@{}", item_name, item_url, revision.unwrap_or("main")))?;
git_update(item_path, item_url, revision).with_context(|| {
format!(
"Error updating {} to {}@{}",
item_name,
item_url,
revision.unwrap_or("main")
)
})?;

if !is_quiet {
println!("{} up to date", item_name);
Expand All @@ -36,7 +48,13 @@ pub fn update(config_path: &Path, data_path: &Path, is_quiet: bool) -> Result<()
for item in items {
let item_path = hooks_path.join(&item.name);

update_item(item.name.as_str(), item.path.as_str(), &item_path, item.revision.as_deref(), is_quiet)?;
update_item(
item.name.as_str(),
item.path.as_str(),
&item_path,
item.revision.as_deref(),
is_quiet,
)?;
}

let schemes_repo_path = hooks_path.join(SCHEMES_REPO_NAME);
Expand Down

0 comments on commit 91f5701

Please sign in to comment.