Revert "Convert git status calculation to use Entry IDs as the key instead of repo relative paths"

This reverts commit 728c6892c924ebeabb086e308ec4b5f56c4fd72a.
This commit is contained in:
Mikayla Maki 2023-05-10 08:49:30 -07:00 committed by Mikayla Maki
parent 21e1bdc8cd
commit 0082d68d4a
No known key found for this signature in database
7 changed files with 59 additions and 90 deletions

View file

@ -13,6 +13,7 @@ gpui = { path = "../gpui" }
lsp = { path = "../lsp" }
rope = { path = "../rope" }
util = { path = "../util" }
sum_tree = { path = "../sum_tree" }
anyhow.workspace = true
async-trait.workspace = true
futures.workspace = true

View file

@ -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;
@ -27,7 +27,7 @@ use util::ResultExt;
#[cfg(any(test, feature = "test-support"))]
use collections::{btree_map, BTreeMap};
#[cfg(any(test, feature = "test-support"))]
use repository::{FakeGitRepositoryState, GitStatus};
use repository::FakeGitRepositoryState;
#[cfg(any(test, feature = "test-support"))]
use std::sync::Weak;

View file

@ -8,6 +8,7 @@ use std::{
path::{Component, Path, PathBuf},
sync::Arc,
};
use sum_tree::TreeMap;
use util::ResultExt;
pub use git2::Repository as LibGitRepository;
@ -20,7 +21,7 @@ pub trait GitRepository: Send {
fn branch_name(&self) -> Option<String>;
fn statuses(&self) -> Option<HashMap<RepoPath, GitStatus>>;
fn statuses(&self) -> Option<TreeMap<RepoPath, GitStatus>>;
fn file_status(&self, path: &RepoPath) -> Option<GitStatus>;
}
@ -69,10 +70,10 @@ impl GitRepository for LibGitRepository {
Some(branch.to_string())
}
fn statuses(&self) -> Option<HashMap<RepoPath, GitStatus>> {
fn statuses(&self) -> Option<TreeMap<RepoPath, GitStatus>> {
let statuses = self.statuses(None).log_err()?;
let mut result = HashMap::default();
let mut map = TreeMap::default();
for status in statuses
.iter()
@ -80,10 +81,10 @@ impl GitRepository for LibGitRepository {
{
let path = RepoPath(PathBuf::from(OsStr::from_bytes(status.path_bytes())));
result.insert(path, status.status().into());
map.insert(path, status.status().into())
}
Some(result)
Some(map)
}
fn file_status(&self, path: &RepoPath) -> Option<GitStatus> {
@ -125,9 +126,9 @@ impl GitRepository for FakeGitRepository {
state.branch_name.clone()
}
fn statuses(&self) -> Option<HashMap<RepoPath, GitStatus>> {
fn statuses(&self) -> Option<TreeMap<RepoPath, GitStatus>> {
let state = self.state.lock();
let mut map = HashMap::default();
let mut map = TreeMap::default();
for (repo_path, status) in state.git_statuses.iter() {
map.insert(repo_path.to_owned(), status.to_owned());
}