Directly parse .git when it's a file instead of using libgit2 (#27885)

Avoids building a whole git2 repository object at the worktree layer
just to watch some additional paths.

- [x] Tidy up names of the various paths
- [x] Tests for worktrees and submodules

Release Notes:

- N/A
This commit is contained in:
Cole Miller 2025-04-11 20:35:14 -04:00 committed by GitHub
parent 429d4580cf
commit 055df30757
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 401 additions and 160 deletions

View file

@ -48,6 +48,8 @@ use debugger::{
session::Session,
};
pub use environment::ProjectEnvironment;
#[cfg(test)]
use futures::future::join_all;
use futures::{
StreamExt,
channel::mpsc::{self, UnboundedReceiver},
@ -4808,6 +4810,30 @@ impl Project {
&self.git_store
}
#[cfg(test)]
fn git_scans_complete(&self, cx: &Context<Self>) -> Task<()> {
cx.spawn(async move |this, cx| {
let scans_complete = this
.read_with(cx, |this, cx| {
this.worktrees(cx)
.filter_map(|worktree| Some(worktree.read(cx).as_local()?.scan_complete()))
.collect::<Vec<_>>()
})
.unwrap();
join_all(scans_complete).await;
let barriers = this
.update(cx, |this, cx| {
let repos = this.repositories(cx).values().cloned().collect::<Vec<_>>();
repos
.into_iter()
.map(|repo| repo.update(cx, |repo, _| repo.barrier()))
.collect::<Vec<_>>()
})
.unwrap();
join_all(barriers).await;
})
}
pub fn active_repository(&self, cx: &App) -> Option<Entity<Repository>> {
self.git_store.read(cx).active_repository()
}