WIP, re-doing fs and fake git repos

This commit is contained in:
Mikayla Maki
2022-09-29 13:16:02 -04:00
committed by Julia
parent d5fd531743
commit 71b2126eca
7 changed files with 145 additions and 50 deletions
+10
View File
@@ -1,6 +1,7 @@
use anyhow::{anyhow, Result};
use fsevent::EventStream;
use futures::{future::BoxFuture, Stream, StreamExt};
use git::repository::{FakeGitRepository, GitRepository, RealGitRepository};
use language::LineEnding;
use smol::io::{AsyncReadExt, AsyncWriteExt};
use std::{
@@ -43,6 +44,7 @@ pub trait Fs: Send + Sync {
path: &Path,
latency: Duration,
) -> Pin<Box<dyn Send + Stream<Item = Vec<fsevent::Event>>>>;
async fn open_repo(&self, abs_dot_git: &Path) -> Option<Box<dyn GitRepository>>;
fn is_fake(&self) -> bool;
#[cfg(any(test, feature = "test-support"))]
fn as_fake(&self) -> &FakeFs;
@@ -236,6 +238,10 @@ impl Fs for RealFs {
})))
}
fn open_repo(&self, abs_dot_git: &Path) -> Option<Box<dyn GitRepository>> {
RealGitRepository::open(&abs_dot_git)
}
fn is_fake(&self) -> bool {
false
}
@@ -847,6 +853,10 @@ impl Fs for FakeFs {
}))
}
fn open_repo(&self, abs_dot_git: &Path) -> Option<Box<dyn GitRepository>> {
Some(FakeGitRepository::open(abs_dot_git.into(), 0))
}
fn is_fake(&self) -> bool {
true
}