Finish removing git repository state and scanning logic from worktrees (#27568)

This PR completes the process of moving git repository state storage and
scanning logic from the worktree crate to `project::git_store`.

Release Notes:

- N/A

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
Cole Miller 2025-04-01 17:41:20 -04:00 committed by GitHub
parent 8f25251faf
commit e7290df02b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 3121 additions and 3529 deletions

View file

@ -123,7 +123,7 @@ impl GitRepository for FakeGitRepository {
&self,
path: RepoPath,
content: Option<String>,
_env: HashMap<String, String>,
_env: Arc<HashMap<String, String>>,
) -> BoxFuture<anyhow::Result<()>> {
self.with_state_async(true, move |state| {
if let Some(message) = state.simulated_index_write_error_message.clone() {
@ -157,7 +157,7 @@ impl GitRepository for FakeGitRepository {
&self,
_commit: String,
_mode: ResetMode,
_env: HashMap<String, String>,
_env: Arc<HashMap<String, String>>,
) -> BoxFuture<Result<()>> {
unimplemented!()
}
@ -166,7 +166,7 @@ impl GitRepository for FakeGitRepository {
&self,
_commit: String,
_paths: Vec<RepoPath>,
_env: HashMap<String, String>,
_env: Arc<HashMap<String, String>>,
) -> BoxFuture<Result<()>> {
unimplemented!()
}
@ -179,7 +179,11 @@ impl GitRepository for FakeGitRepository {
self.path()
}
fn status_blocking(&self, path_prefixes: &[RepoPath]) -> Result<GitStatus> {
fn merge_message(&self) -> BoxFuture<Option<String>> {
async move { None }.boxed()
}
fn status(&self, path_prefixes: &[RepoPath]) -> BoxFuture<Result<GitStatus>> {
let workdir_path = self.dot_git_path.parent().unwrap();
// Load gitignores
@ -221,7 +225,7 @@ impl GitRepository for FakeGitRepository {
})
.collect();
self.fs.with_git_state(&self.dot_git_path, false, |state| {
let result = self.fs.with_git_state(&self.dot_git_path, false, |state| {
let mut entries = Vec::new();
let paths = state
.head_contents
@ -302,10 +306,11 @@ impl GitRepository for FakeGitRepository {
}
}
entries.sort_by(|a, b| a.0.cmp(&b.0));
Ok(GitStatus {
anyhow::Ok(GitStatus {
entries: entries.into(),
})
})?
});
async move { result? }.boxed()
}
fn branches(&self) -> BoxFuture<Result<Vec<Branch>>> {
@ -351,7 +356,7 @@ impl GitRepository for FakeGitRepository {
fn stage_paths(
&self,
_paths: Vec<RepoPath>,
_env: HashMap<String, String>,
_env: Arc<HashMap<String, String>>,
) -> BoxFuture<Result<()>> {
unimplemented!()
}
@ -359,7 +364,7 @@ impl GitRepository for FakeGitRepository {
fn unstage_paths(
&self,
_paths: Vec<RepoPath>,
_env: HashMap<String, String>,
_env: Arc<HashMap<String, String>>,
) -> BoxFuture<Result<()>> {
unimplemented!()
}
@ -368,7 +373,7 @@ impl GitRepository for FakeGitRepository {
&self,
_message: gpui::SharedString,
_name_and_email: Option<(gpui::SharedString, gpui::SharedString)>,
_env: HashMap<String, String>,
_env: Arc<HashMap<String, String>>,
) -> BoxFuture<Result<()>> {
unimplemented!()
}
@ -379,7 +384,7 @@ impl GitRepository for FakeGitRepository {
_remote: String,
_options: Option<PushOptions>,
_askpass: AskPassDelegate,
_env: HashMap<String, String>,
_env: Arc<HashMap<String, String>>,
_cx: AsyncApp,
) -> BoxFuture<Result<git::repository::RemoteCommandOutput>> {
unimplemented!()
@ -390,7 +395,7 @@ impl GitRepository for FakeGitRepository {
_branch: String,
_remote: String,
_askpass: AskPassDelegate,
_env: HashMap<String, String>,
_env: Arc<HashMap<String, String>>,
_cx: AsyncApp,
) -> BoxFuture<Result<git::repository::RemoteCommandOutput>> {
unimplemented!()
@ -399,7 +404,7 @@ impl GitRepository for FakeGitRepository {
fn fetch(
&self,
_askpass: AskPassDelegate,
_env: HashMap<String, String>,
_env: Arc<HashMap<String, String>>,
_cx: AsyncApp,
) -> BoxFuture<Result<git::repository::RemoteCommandOutput>> {
unimplemented!()