Move git state to Project (#23208)

This restores its visibility outside of git_ui, which we'll need soon,
while preserving its per-project character.

Release Notes:

- N/A
This commit is contained in:
Cole Miller 2025-01-16 13:57:28 -05:00 committed by GitHub
parent 614eaec278
commit b7726238ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 363 additions and 317 deletions

View file

@ -2583,6 +2583,17 @@ impl Snapshot {
&self.repositories
}
pub fn repositories_with_abs_paths(
&self,
) -> impl '_ + Iterator<Item = (&RepositoryEntry, PathBuf)> {
let base = self.abs_path();
self.repositories.iter().map(|repo| {
let path = repo.work_directory.location_in_repo.as_deref();
let path = path.unwrap_or(repo.work_directory.as_ref());
(repo, base.join(path))
})
}
/// Get the repository whose work directory corresponds to the given path.
pub(crate) fn repository(&self, work_directory: PathKey) -> Option<RepositoryEntry> {
self.repositories.get(&work_directory, &()).cloned()