aboutsummaryrefslogtreecommitdiff
path: root/src/repo/aggregate.rs
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2024-03-27 12:57:30 +0100
committerMax Audron <audron@cocaine.farm>2024-03-27 12:57:30 +0100
commit3a88527328952ddffef0bf228f0832e81fcfdf19 (patch)
tree8de19b16c5038537a714d2bfe34892d20e6d5626 /src/repo/aggregate.rs
parentrelease 1.0.4 (diff)
implement basic cloning and updating with gix
Diffstat (limited to 'src/repo/aggregate.rs')
-rw-r--r--src/repo/aggregate.rs22
1 files changed, 10 insertions, 12 deletions
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;
}