WIP: integrate status with collab
This commit is contained in:
parent
18cec8d64f
commit
a58a33fc93
5 changed files with 154 additions and 5 deletions
|
@ -7,7 +7,7 @@ use git2::Repository as LibGitRepository;
|
|||
use lazy_static::lazy_static;
|
||||
use parking_lot::Mutex;
|
||||
use regex::Regex;
|
||||
use repository::GitRepository;
|
||||
use repository::{GitRepository, GitStatus};
|
||||
use rope::Rope;
|
||||
use smol::io::{AsyncReadExt, AsyncWriteExt};
|
||||
use std::borrow::Cow;
|
||||
|
@ -654,6 +654,19 @@ impl FakeFs {
|
|||
});
|
||||
}
|
||||
|
||||
pub async fn set_status_for_repo(&self, dot_git: &Path, statuses: &[(&Path, GitStatus)]) {
|
||||
self.with_git_state(dot_git, |state| {
|
||||
state.git_statuses.clear();
|
||||
state.git_statuses.extend(
|
||||
statuses
|
||||
.iter()
|
||||
.map(|(path, content)| {
|
||||
((**path).into(), content.clone())
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
pub fn paths(&self) -> Vec<PathBuf> {
|
||||
let mut result = Vec::new();
|
||||
let mut queue = collections::VecDeque::new();
|
||||
|
|
|
@ -102,6 +102,7 @@ pub struct FakeGitRepository {
|
|||
#[derive(Debug, Clone, Default)]
|
||||
pub struct FakeGitRepositoryState {
|
||||
pub index_contents: HashMap<PathBuf, String>,
|
||||
pub git_statuses: HashMap<RepoPath, GitStatus>,
|
||||
pub branch_name: Option<String>,
|
||||
}
|
||||
|
||||
|
@ -126,11 +127,17 @@ impl GitRepository for FakeGitRepository {
|
|||
}
|
||||
|
||||
fn statuses(&self) -> Option<TreeMap<RepoPath, GitStatus>> {
|
||||
todo!()
|
||||
let state = self.state.lock();
|
||||
let mut map = TreeMap::default();
|
||||
for (repo_path, status) in state.git_statuses.iter() {
|
||||
map.insert(repo_path.to_owned(), status.to_owned());
|
||||
}
|
||||
Some(map)
|
||||
}
|
||||
|
||||
fn file_status(&self, _: &RepoPath) -> Option<GitStatus> {
|
||||
todo!()
|
||||
fn file_status(&self, path: &RepoPath) -> Option<GitStatus> {
|
||||
let state = self.state.lock();
|
||||
state.git_statuses.get(path).cloned()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue