From 3a88527328952ddffef0bf228f0832e81fcfdf19 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Wed, 27 Mar 2024 12:57:30 +0100 Subject: implement basic cloning and updating with gix --- src/repo/aggregate.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/repo/aggregate.rs') diff --git a/src/repo/aggregate.rs b/src/repo/aggregate.rs index d5a59ba..f8e44a5 100644 --- a/src/repo/aggregate.rs +++ b/src/repo/aggregate.rs @@ -1,11 +1,7 @@ -use std::{ - collections::HashMap, - sync::RwLock, -}; +use std::{collections::HashMap, os::unix::ffi::OsStrExt, sync::RwLock}; -use git2::Repository; - -use tracing::error; +use gix::bstr::ByteSlice; +use tracing::{debug, error}; use walkdir::WalkDir; use crate::forge::Project; @@ -25,7 +21,7 @@ impl Aggregator for Repos { fn from_local(root: &str, scope: &str) -> Repos { let mut repos = HashMap::new(); - let path: std::path::PathBuf = [root, scope].iter().collect(); + let path: std::path::PathBuf = root.into(); if !path.exists() { return repos; @@ -40,7 +36,8 @@ impl Aggregator for Repos { Some(Ok(entry)) => entry, }; - if entry.file_type().is_dir() { + if entry.file_type().is_dir() && entry.path().as_os_str().as_bytes().contains_str(scope) + { let mut dir = std::fs::read_dir(entry.path()).unwrap(); if dir.any(|dir| { @@ -52,7 +49,9 @@ impl Aggregator for Repos { }) { walker.skip_current_dir(); - match Repository::open(entry.path()) { + debug!("found git repo {:?} trying to open...", entry.path()); + + match gix::open(entry.path()) { Ok(repo) => { let name = entry .path() @@ -104,8 +103,7 @@ impl Aggregator for Repos { local = local .into_iter() .map(|(left_name, left)| { - if let Some(right) = remote.remove(&left_name) - { + if let Some(right) = remote.remove(&left_name) { left.write().unwrap().forge = right.into_inner().unwrap().forge; } -- cgit v1.2.3