Make GitRepository::status async and remove cx parameter (#27514)

This lays the groundwork for using `status` as part of the new agent
panel.

Release Notes:

- N/A
This commit is contained in:
Antonio Scandurra 2025-03-27 10:05:54 +01:00 committed by GitHub
parent 926d10cc45
commit 7354ef91e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 662 additions and 716 deletions

View file

@ -773,11 +773,11 @@ impl GitStore {
anyhow::Ok(Some((repo, relative_path, content)))
});
cx.spawn(async move |cx| {
cx.spawn(async move |_cx| {
let Some((repo, relative_path, content)) = blame_params? else {
return Ok(None);
};
repo.blame(relative_path.clone(), content, cx)
repo.blame(relative_path.clone(), content)
.await
.with_context(|| format!("Failed to blame {:?}", relative_path.0))
.map(Some)
@ -1282,16 +1282,13 @@ impl GitStore {
let index_text = if current_index_text.is_some() {
local_repo
.repo()
.load_index_text(relative_path.clone(), cx.clone())
.load_index_text(relative_path.clone())
.await
} else {
None
};
let head_text = if current_head_text.is_some() {
local_repo
.repo()
.load_committed_text(relative_path, cx.clone())
.await
local_repo.repo().load_committed_text(relative_path).await
} else {
None
};
@ -2832,9 +2829,9 @@ impl Repository {
}
pub fn show(&self, commit: String) -> oneshot::Receiver<Result<CommitDetails>> {
self.send_job(|git_repo, cx| async move {
self.send_job(|git_repo, _cx| async move {
match git_repo {
RepositoryState::Local(git_repository) => git_repository.show(commit, cx).await,
RepositoryState::Local(git_repository) => git_repository.show(commit).await,
RepositoryState::Remote {
project_id,
client,
@ -2901,9 +2898,9 @@ impl Repository {
let env = env.await;
this.update(cx, |this, _| {
this.send_job(|git_repo, cx| async move {
this.send_job(|git_repo, _cx| async move {
match git_repo {
RepositoryState::Local(repo) => repo.stage_paths(entries, env, cx).await,
RepositoryState::Local(repo) => repo.stage_paths(entries, env).await,
RepositoryState::Remote {
project_id,
client,
@ -2969,9 +2966,9 @@ impl Repository {
let env = env.await;
this.update(cx, |this, _| {
this.send_job(|git_repo, cx| async move {
this.send_job(|git_repo, _cx| async move {
match git_repo {
RepositoryState::Local(repo) => repo.unstage_paths(entries, env, cx).await,
RepositoryState::Local(repo) => repo.unstage_paths(entries, env).await,
RepositoryState::Remote {
project_id,
client,
@ -3055,11 +3052,11 @@ impl Repository {
cx: &mut App,
) -> oneshot::Receiver<Result<()>> {
let env = self.worktree_environment(cx);
self.send_job(|git_repo, cx| async move {
self.send_job(|git_repo, _cx| async move {
match git_repo {
RepositoryState::Local(repo) => {
let env = env.await;
repo.commit(message, name_and_email, env, cx).await
repo.commit(message, name_and_email, env).await
}
RepositoryState::Remote {
project_id,
@ -3254,10 +3251,10 @@ impl Repository {
self.send_keyed_job(
Some(GitJobKey::WriteIndex(path.clone())),
|git_repo, cx| async {
|git_repo, _cx| async {
match git_repo {
RepositoryState::Local(repo) => {
repo.set_index_text(path, content, env.await, cx).await
repo.set_index_text(path, content, env.await).await
}
RepositoryState::Remote {
project_id,
@ -3283,10 +3280,10 @@ impl Repository {
&self,
branch_name: Option<String>,
) -> oneshot::Receiver<Result<Vec<Remote>>> {
self.send_job(|repo, cx| async move {
self.send_job(|repo, _cx| async move {
match repo {
RepositoryState::Local(git_repository) => {
git_repository.get_remotes(branch_name, cx).await
git_repository.get_remotes(branch_name).await
}
RepositoryState::Remote {
project_id,
@ -3352,9 +3349,9 @@ impl Repository {
}
pub fn diff(&self, diff_type: DiffType, _cx: &App) -> oneshot::Receiver<Result<String>> {
self.send_job(|repo, cx| async move {
self.send_job(|repo, _cx| async move {
match repo {
RepositoryState::Local(git_repository) => git_repository.diff(diff_type, cx).await,
RepositoryState::Local(git_repository) => git_repository.diff(diff_type).await,
RepositoryState::Remote {
project_id,
client,
@ -3383,10 +3380,10 @@ impl Repository {
}
pub fn create_branch(&self, branch_name: String) -> oneshot::Receiver<Result<()>> {
self.send_job(|repo, cx| async move {
self.send_job(|repo, _cx| async move {
match repo {
RepositoryState::Local(git_repository) => {
git_repository.create_branch(branch_name, cx).await
git_repository.create_branch(branch_name).await
}
RepositoryState::Remote {
project_id,
@ -3408,10 +3405,10 @@ impl Repository {
}
pub fn change_branch(&self, branch_name: String) -> oneshot::Receiver<Result<()>> {
self.send_job(|repo, cx| async move {
self.send_job(|repo, _cx| async move {
match repo {
RepositoryState::Local(git_repository) => {
git_repository.change_branch(branch_name, cx).await
git_repository.change_branch(branch_name).await
}
RepositoryState::Remote {
project_id,
@ -3433,10 +3430,10 @@ impl Repository {
}
pub fn check_for_pushed_commits(&self) -> oneshot::Receiver<Result<Vec<SharedString>>> {
self.send_job(|repo, cx| async move {
self.send_job(|repo, _cx| async move {
match repo {
RepositoryState::Local(git_repository) => {
git_repository.check_for_pushed_commit(cx).await
git_repository.check_for_pushed_commit().await
}
RepositoryState::Remote {
project_id,
@ -3459,9 +3456,9 @@ impl Repository {
}
pub fn checkpoint(&self) -> oneshot::Receiver<Result<GitRepositoryCheckpoint>> {
self.send_job(|repo, cx| async move {
self.send_job(|repo, _cx| async move {
match repo {
RepositoryState::Local(git_repository) => git_repository.checkpoint(cx).await,
RepositoryState::Local(git_repository) => git_repository.checkpoint().await,
RepositoryState::Remote { .. } => Err(anyhow!("not implemented yet")),
}
})
@ -3471,10 +3468,10 @@ impl Repository {
&self,
checkpoint: GitRepositoryCheckpoint,
) -> oneshot::Receiver<Result<()>> {
self.send_job(move |repo, cx| async move {
self.send_job(move |repo, _cx| async move {
match repo {
RepositoryState::Local(git_repository) => {
git_repository.restore_checkpoint(checkpoint, cx).await
git_repository.restore_checkpoint(checkpoint).await
}
RepositoryState::Remote { .. } => Err(anyhow!("not implemented yet")),
}
@ -3513,10 +3510,10 @@ impl Repository {
left: GitRepositoryCheckpoint,
right: GitRepositoryCheckpoint,
) -> oneshot::Receiver<Result<bool>> {
self.send_job(move |repo, cx| async move {
self.send_job(move |repo, _cx| async move {
match repo {
RepositoryState::Local(git_repository) => {
git_repository.compare_checkpoints(left, right, cx).await
git_repository.compare_checkpoints(left, right).await
}
RepositoryState::Remote { .. } => Err(anyhow!("not implemented yet")),
}
@ -3527,10 +3524,10 @@ impl Repository {
&self,
checkpoint: GitRepositoryCheckpoint,
) -> oneshot::Receiver<Result<()>> {
self.send_job(move |repo, cx| async move {
self.send_job(move |repo, _cx| async move {
match repo {
RepositoryState::Local(git_repository) => {
git_repository.delete_checkpoint(checkpoint, cx).await
git_repository.delete_checkpoint(checkpoint).await
}
RepositoryState::Remote { .. } => Err(anyhow!("not implemented yet")),
}

View file

@ -1476,7 +1476,7 @@ impl Project {
) -> Entity<Project> {
use clock::FakeSystemClock;
let fs = Arc::new(RealFs::default());
let fs = Arc::new(RealFs::new(None, cx.background_executor().clone()));
let languages = LanguageRegistry::test(cx.background_executor().clone());
let clock = Arc::new(FakeSystemClock::new());
let http_client = http_client::FakeHttpClient::with_404_response();

View file

@ -99,7 +99,12 @@ async fn test_symlinks(cx: &mut gpui::TestAppContext) {
)
.unwrap();
let project = Project::test(Arc::new(RealFs::default()), [root_link_path.as_ref()], cx).await;
let project = Project::test(
Arc::new(RealFs::new(None, cx.executor())),
[root_link_path.as_ref()],
cx,
)
.await;
project.update(cx, |project, cx| {
let tree = project.worktrees(cx).next().unwrap().read(cx);
@ -3332,7 +3337,7 @@ async fn test_rescan_and_remote_updates(cx: &mut gpui::TestAppContext) {
}
}));
let project = Project::test(Arc::new(RealFs::default()), [dir.path()], cx).await;
let project = Project::test(Arc::new(RealFs::new(None, cx.executor())), [dir.path()], cx).await;
let buffer_for_path = |path: &'static str, cx: &mut gpui::TestAppContext| {
let buffer = project.update(cx, |p, cx| p.open_local_buffer(dir.path().join(path), cx));