Simplify project git code (#25662)

This was originally a part of another PR, but I wanted to get the
refactoring in and shift focus to working on bugs.

This causes all git commands via the `Repository` entity to be
serialized, and allows us to return values other than `Result<()>`

Release Notes:

- N/A
This commit is contained in:
Mikayla Maki 2025-02-26 10:16:10 -08:00 committed by GitHub
parent 78da39e19b
commit 5edded5c02
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 365 additions and 433 deletions

View file

@ -1386,14 +1386,14 @@ impl GitPanel {
};
let mut current_remotes: Vec<Remote> = repo
.update(&mut cx, |repo, cx| {
.update(&mut cx, |repo, _| {
let Some(current_branch) = repo.current_branch() else {
return Err(anyhow::anyhow!("No active branch"));
};
Ok(repo.get_remotes(Some(current_branch.name.to_string()), cx))
Ok(repo.get_remotes(Some(current_branch.name.to_string())))
})??
.await?;
.await??;
if current_remotes.len() == 0 {
return Err(anyhow::anyhow!("No active remote"));
@ -2357,7 +2357,9 @@ impl GitPanel {
let Some(repo) = self.active_repository.clone() else {
return Task::ready(Err(anyhow::anyhow!("no active repo")));
};
repo.update(cx, |repo, cx| repo.show(sha, cx))
let show = repo.read(cx).show(sha);
cx.spawn(|_, _| async move { show.await? })
}
fn deploy_entry_context_menu(