Add git status to the file system abstraction

co-authored-by: petros <petros@zed.dev>
This commit is contained in:
Mikayla Maki 2023-05-09 08:36:43 -07:00 committed by Mikayla Maki
parent 6385e51957
commit 7169f5c760
No known key found for this signature in database
4 changed files with 94 additions and 27 deletions

View file

@ -6,7 +6,7 @@ use anyhow::{anyhow, Context, Result};
use client::{proto, Client};
use clock::ReplicaId;
use collections::{HashMap, VecDeque};
use fs::{repository::GitRepository, Fs, LineEnding};
use fs::{repository::{GitRepository, RepoPath, GitStatus}, Fs, LineEnding};
use futures::{
channel::{
mpsc::{self, UnboundedSender},
@ -117,10 +117,11 @@ pub struct Snapshot {
completed_scan_id: usize,
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct RepositoryEntry {
pub(crate) work_directory: WorkDirectoryEntry,
pub(crate) branch: Option<Arc<str>>,
// pub(crate) statuses: TreeMap<RepoPath, GitStatus>
}
impl RepositoryEntry {
@ -162,6 +163,13 @@ impl Default for RepositoryWorkDirectory {
}
}
impl AsRef<Path> for RepositoryWorkDirectory {
fn as_ref(&self) -> &Path {
self.0.as_ref()
}
}
#[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq)]
pub struct WorkDirectoryEntry(ProjectEntryId);
@ -178,7 +186,7 @@ impl WorkDirectoryEntry {
worktree.entry_for_id(self.0).and_then(|entry| {
path.strip_prefix(&entry.path)
.ok()
.map(move |path| RepoPath(path.to_owned()))
.map(move |path| path.into())
})
}
}
@ -197,29 +205,6 @@ impl<'a> From<ProjectEntryId> for WorkDirectoryEntry {
}
}
#[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq)]
pub struct RepoPath(PathBuf);
impl AsRef<Path> for RepoPath {
fn as_ref(&self) -> &Path {
self.0.as_ref()
}
}
impl Deref for RepoPath {
type Target = PathBuf;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl AsRef<Path> for RepositoryWorkDirectory {
fn as_ref(&self) -> &Path {
self.0.as_ref()
}
}
#[derive(Debug, Clone)]
pub struct LocalSnapshot {
ignores_by_parent_abs_path: HashMap<Arc<Path>, (Arc<Gitignore>, usize)>,