From 33d0340729384532c6ed8660731ac917f0d8aaff Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Tue, 18 Mar 2025 12:23:46 -0400 Subject: [PATCH] worktree: Fix tracking of git status scans and re-enable tests (#26926) Closes #ISSUE Release Notes: - N/A --- crates/worktree/src/worktree.rs | 6 +++++- crates/worktree/src/worktree_tests.rs | 10 +--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 8cd3b09fe705172aa560eb9968795b392a608d05..744c87ecc9f9decaa9c16339f90ad32e96c9139c 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -5464,6 +5464,7 @@ impl BackgroundScanner { } }; + inc_scans_running(&self.scans_running); status_updates .push(self.schedule_git_statuses_update(&mut state, local_repository)); } @@ -5496,9 +5497,12 @@ impl BackgroundScanner { }); } + let scans_running = self.scans_running.clone(); self.executor.spawn(async move { - let _updates_finished: Vec> = + let updates_finished: Vec> = join_all(status_updates).await; + let n = updates_finished.len(); + dec_scans_running(&scans_running, n as i32); }) } diff --git a/crates/worktree/src/worktree_tests.rs b/crates/worktree/src/worktree_tests.rs index 43b68ba081e6054bace251a87b5772406627d6f5..667ac9cead45597f7064889140be696ce3dddac4 100644 --- a/crates/worktree/src/worktree_tests.rs +++ b/crates/worktree/src/worktree_tests.rs @@ -2430,9 +2430,7 @@ async fn test_git_repository_for_path(cx: &mut TestAppContext) { // you can't rename a directory which some program has already open. This is a // limitation of the Windows. See: // https://stackoverflow.com/questions/41365318/access-is-denied-when-renaming-folder -// TODO: re-enable flaky test. -//#[gpui::test] -#[allow(dead_code)] +#[gpui::test] #[cfg_attr(target_os = "windows", ignore)] async fn test_file_status(cx: &mut TestAppContext) { init_test(cx); @@ -3535,8 +3533,6 @@ fn git_cherry_pick(commit: &git2::Commit<'_>, repo: &git2::Repository) { repo.cherrypick(commit, None).expect("Failed to cherrypick"); } -// TODO remove this once flaky test is fixed -#[allow(dead_code)] #[track_caller] fn git_stash(repo: &mut git2::Repository) { use git2::Signature; @@ -3546,8 +3542,6 @@ fn git_stash(repo: &mut git2::Repository) { .expect("Failed to stash"); } -// TODO remove this once flaky test is fixed -#[allow(dead_code)] #[track_caller] fn git_reset(offset: usize, repo: &git2::Repository) { let head = repo.head().expect("Couldn't get repo head"); @@ -3580,8 +3574,6 @@ fn git_checkout(name: &str, repo: &git2::Repository) { repo.checkout_head(None).expect("Failed to check out head"); } -// TODO remove this once flaky test is fixed -#[allow(dead_code)] #[track_caller] fn git_status(repo: &git2::Repository) -> collections::HashMap { repo.statuses(None)