mirror of
https://github.com/encounter/zed.git
synced 2026-03-30 11:44:33 -07:00
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:
@@ -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>> {
|
||||
|
||||
@@ -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
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user