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
3 changed files with 365 additions and 433 deletions
+6 -9
View File
@@ -618,10 +618,9 @@ impl GitRepository for RealGitRepository {
"Failed to push:\n{}",
String::from_utf8_lossy(&output.stderr)
));
} else {
Ok(())
}
// TODO: Get remote response out of this and show it to the user
Ok(())
}
fn pull(&self, branch_name: &str, remote_name: &str) -> Result<()> {
@@ -639,10 +638,9 @@ impl GitRepository for RealGitRepository {
"Failed to pull:\n{}",
String::from_utf8_lossy(&output.stderr)
));
} else {
return Ok(());
}
// TODO: Get remote response out of this and show it to the user
Ok(())
}
fn fetch(&self) -> Result<()> {
@@ -658,10 +656,9 @@ impl GitRepository for RealGitRepository {
"Failed to fetch:\n{}",
String::from_utf8_lossy(&output.stderr)
));
} else {
return Ok(());
}
// TODO: Get remote response out of this and show it to the user
Ok(())
}
fn get_remotes(&self, branch_name: Option<&str>) -> Result<Vec<Remote>> {
+6 -4
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(
+353 -420
View File
File diff suppressed because it is too large Load Diff