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

@ -1035,16 +1035,13 @@ impl Worktree {
Worktree::Local(this) => {
let path = Arc::from(path);
let snapshot = this.snapshot();
cx.spawn(async move |cx| {
cx.spawn(async move |_cx| {
if let Some(repo) = snapshot.local_repo_containing_path(&path) {
if let Some(repo_path) = repo.relativize(&path).log_err() {
if let Some(git_repo) =
snapshot.git_repositories.get(&repo.work_directory_id)
{
return Ok(git_repo
.repo_ptr
.load_index_text(repo_path, cx.clone())
.await);
return Ok(git_repo.repo_ptr.load_index_text(repo_path).await);
}
}
}
@ -1062,16 +1059,13 @@ impl Worktree {
Worktree::Local(this) => {
let path = Arc::from(path);
let snapshot = this.snapshot();
cx.spawn(async move |cx| {
cx.spawn(async move |_cx| {
if let Some(repo) = snapshot.local_repo_containing_path(&path) {
if let Some(repo_path) = repo.relativize(&path).log_err() {
if let Some(git_repo) =
snapshot.git_repositories.get(&repo.work_directory_id)
{
return Ok(git_repo
.repo_ptr
.load_committed_text(repo_path, cx.clone())
.await);
return Ok(git_repo.repo_ptr.load_committed_text(repo_path).await);
}
}
}
@ -5027,7 +5021,7 @@ impl BackgroundScanner {
}
for (_work_directory, mut paths) in paths_by_git_repo {
if let Ok(status) = paths.repo.status(&paths.repo_paths) {
if let Ok(status) = paths.repo.status_blocking(&paths.repo_paths) {
let mut changed_path_statuses = Vec::new();
let statuses = paths.entry.statuses_by_path.clone();
let mut cursor = statuses.cursor::<PathProgress>(&());
@ -5531,7 +5525,7 @@ async fn do_git_status_update(
log::trace!("updating git statuses for repo {repository_name}");
let Some(statuses) = local_repository
.repo()
.status(&[git::WORK_DIRECTORY_REPO_PATH.clone()])
.status_blocking(&[git::WORK_DIRECTORY_REPO_PATH.clone()])
.log_err()
else {
return;

View file

@ -351,7 +351,7 @@ async fn test_renaming_case_only(cx: &mut TestAppContext) {
const OLD_NAME: &str = "aaa.rs";
const NEW_NAME: &str = "AAA.rs";
let fs = Arc::new(RealFs::default());
let fs = Arc::new(RealFs::new(None, cx.executor()));
let temp_root = TempTree::new(json!({
OLD_NAME: "",
}));
@ -876,7 +876,7 @@ async fn test_write_file(cx: &mut TestAppContext) {
let worktree = Worktree::local(
dir.path(),
true,
Arc::new(RealFs::default()),
Arc::new(RealFs::new(None, cx.executor())),
Default::default(),
&mut cx.to_async(),
)
@ -965,7 +965,7 @@ async fn test_file_scan_inclusions(cx: &mut TestAppContext) {
let tree = Worktree::local(
dir.path(),
true,
Arc::new(RealFs::default()),
Arc::new(RealFs::new(None, cx.executor())),
Default::default(),
&mut cx.to_async(),
)
@ -1028,7 +1028,7 @@ async fn test_file_scan_exclusions_overrules_inclusions(cx: &mut TestAppContext)
let tree = Worktree::local(
dir.path(),
true,
Arc::new(RealFs::default()),
Arc::new(RealFs::new(None, cx.executor())),
Default::default(),
&mut cx.to_async(),
)
@ -1085,7 +1085,7 @@ async fn test_file_scan_inclusions_reindexes_on_setting_change(cx: &mut TestAppC
let tree = Worktree::local(
dir.path(),
true,
Arc::new(RealFs::default()),
Arc::new(RealFs::new(None, cx.executor())),
Default::default(),
&mut cx.to_async(),
)
@ -1166,7 +1166,7 @@ async fn test_file_scan_exclusions(cx: &mut TestAppContext) {
let tree = Worktree::local(
dir.path(),
true,
Arc::new(RealFs::default()),
Arc::new(RealFs::new(None, cx.executor())),
Default::default(),
&mut cx.to_async(),
)
@ -1271,7 +1271,7 @@ async fn test_fs_events_in_exclusions(cx: &mut TestAppContext) {
let tree = Worktree::local(
dir.path(),
true,
Arc::new(RealFs::default()),
Arc::new(RealFs::new(None, cx.executor())),
Default::default(),
&mut cx.to_async(),
)
@ -1382,7 +1382,7 @@ async fn test_fs_events_in_dot_git_worktree(cx: &mut TestAppContext) {
let tree = Worktree::local(
dot_git_worktree_dir.clone(),
true,
Arc::new(RealFs::default()),
Arc::new(RealFs::new(None, cx.executor())),
Default::default(),
&mut cx.to_async(),
)
@ -1512,7 +1512,7 @@ async fn test_create_dir_all_on_create_entry(cx: &mut TestAppContext) {
assert!(tree.entry_for_path("a/b/").unwrap().is_dir());
});
let fs_real = Arc::new(RealFs::default());
let fs_real = Arc::new(RealFs::new(None, cx.executor()));
let temp_root = TempTree::new(json!({
"a": {}
}));
@ -2126,7 +2126,7 @@ async fn test_rename_work_directory(cx: &mut TestAppContext) {
let tree = Worktree::local(
root_path,
true,
Arc::new(RealFs::default()),
Arc::new(RealFs::new(None, cx.executor())),
Default::default(),
&mut cx.to_async(),
)
@ -2233,7 +2233,7 @@ async fn test_file_status(cx: &mut TestAppContext) {
let tree = Worktree::local(
root.path(),
true,
Arc::new(RealFs::default()),
Arc::new(RealFs::new(None, cx.executor())),
Default::default(),
&mut cx.to_async(),
)
@ -2422,7 +2422,7 @@ async fn test_git_repository_status(cx: &mut TestAppContext) {
let tree = Worktree::local(
root.path(),
true,
Arc::new(RealFs::default()),
Arc::new(RealFs::new(None, cx.executor())),
Default::default(),
&mut cx.to_async(),
)
@ -2551,7 +2551,7 @@ async fn test_git_status_postprocessing(cx: &mut TestAppContext) {
let tree = Worktree::local(
root.path(),
true,
Arc::new(RealFs::default()),
Arc::new(RealFs::new(None, cx.executor())),
Default::default(),
&mut cx.to_async(),
)
@ -2619,7 +2619,7 @@ async fn test_repository_subfolder_git_status(cx: &mut TestAppContext) {
let tree = Worktree::local(
root.path().join(project_root),
true,
Arc::new(RealFs::default()),
Arc::new(RealFs::new(None, cx.executor())),
Default::default(),
&mut cx.to_async(),
)
@ -2685,7 +2685,7 @@ async fn test_conflicted_cherry_pick(cx: &mut TestAppContext) {
let tree = Worktree::local(
root_path,
true,
Arc::new(RealFs::default()),
Arc::new(RealFs::new(None, cx.executor())),
Default::default(),
&mut cx.to_async(),
)