Represent git statuses more faithfully (#23082)

First, parse the output of `git status --porcelain=v1` into a
representation that can handle the full "grammar" and doesn't lose
information.

Second, as part of pushing this throughout the codebase, expand the use
of the existing `GitSummary` type to all the places where status
propagation is in play (i.e., anywhere we're dealing with a mix of files
and directories), and get rid of the previous `GitSummary ->
GitFileStatus` conversion.

- [x] Synchronize new representation over collab
  - [x] Update zed.proto
  - [x] Update DB models
- [x] Update `GitSummary` and summarization for the new `FileStatus`
- [x] Fix all tests
  - [x] worktree
  - [x] collab
- [x] Clean up `FILE_*` constants
- [x] New collab tests to exercise syncing of complex statuses
- [x] Run it locally and make sure it looks good

Release Notes:

- N/A

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
Cole Miller 2025-01-15 19:01:38 -05:00 committed by GitHub
parent 224f3d4746
commit a41d72ee81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 1015 additions and 552 deletions

View file

@ -1982,7 +1982,7 @@ impl OutlinePanel {
let is_expanded = !self
.collapsed_entries
.contains(&CollapsedEntry::Excerpt(excerpt.buffer_id, excerpt.id));
let color = entry_git_aware_label_color(None, false, is_active);
let color = entry_label_color(is_active);
let icon = if has_outlines {
FileIcons::get_chevron_icon(is_expanded, cx)
.map(|icon_path| Icon::from_path(icon_path).color(color).into_any_element())
@ -2086,7 +2086,7 @@ impl OutlinePanel {
}) => {
let name = self.entry_name(worktree_id, entry, cx);
let color =
entry_git_aware_label_color(entry.git_status, entry.is_ignored, is_active);
entry_git_aware_label_color(entry.git_summary, entry.is_ignored, is_active);
let icon = if settings.file_icons {
FileIcons::get_icon(&entry.path, cx)
.map(|icon_path| Icon::from_path(icon_path).color(color).into_any_element())
@ -2114,7 +2114,7 @@ impl OutlinePanel {
directory.entry.id,
));
let color = entry_git_aware_label_color(
directory.entry.git_status,
directory.entry.git_summary,
directory.entry.is_ignored,
is_active,
);
@ -2210,7 +2210,8 @@ impl OutlinePanel {
let git_status = folded_dir
.entries
.first()
.and_then(|entry| entry.git_status);
.map(|entry| entry.git_summary)
.unwrap_or_default();
let color = entry_git_aware_label_color(git_status, is_ignored, is_active);
let icon = if settings.folder_icons {
FileIcons::get_folder_icon(is_expanded, cx)
@ -2556,7 +2557,10 @@ impl OutlinePanel {
match entry_id.and_then(|id| worktree.entry_for_id(id)).cloned() {
Some(entry) => {
let entry = GitEntry {
git_status: worktree.status_for_file(&entry.path),
git_summary: worktree
.status_for_file(&entry.path)
.map(|status| status.summary())
.unwrap_or_default(),
entry,
};
let mut traversal = worktree