Update protos

This commit is contained in:
Mikayla Maki 2023-05-10 11:59:04 -07:00
parent 00b345fdfe
commit 2b80dfa81d
No known key found for this signature in database
3 changed files with 20 additions and 19 deletions

View file

@ -1568,8 +1568,8 @@ impl Database {
worktree.updated_repositories.push(proto::RepositoryEntry { worktree.updated_repositories.push(proto::RepositoryEntry {
work_directory_id: db_repository.work_directory_id as u64, work_directory_id: db_repository.work_directory_id as u64,
branch: db_repository.branch, branch: db_repository.branch,
removed_statuses: Default::default(), removed_worktree_repo_paths: Default::default(),
updated_statuses: Default::default(), updated_worktree_statuses: Default::default(),
}); });
} }
@ -2651,8 +2651,8 @@ impl Database {
worktree.repository_entries.push(proto::RepositoryEntry { worktree.repository_entries.push(proto::RepositoryEntry {
work_directory_id: db_repository_entry.work_directory_id as u64, work_directory_id: db_repository_entry.work_directory_id as u64,
branch: db_repository_entry.branch, branch: db_repository_entry.branch,
removed_statuses: Default::default(), removed_worktree_repo_paths: Default::default(),
updated_statuses: Default::default(), updated_worktree_statuses: Default::default(),
}); });
} }

View file

@ -180,8 +180,8 @@ impl From<&RepositoryEntry> for proto::RepositoryEntry {
work_directory_id: value.work_directory.to_proto(), work_directory_id: value.work_directory.to_proto(),
branch: value.branch.as_ref().map(|str| str.to_string()), branch: value.branch.as_ref().map(|str| str.to_string()),
// TODO: Status // TODO: Status
removed_statuses: Default::default(), removed_worktree_repo_paths: Default::default(),
updated_statuses: Default::default(), updated_worktree_statuses: Default::default(),
} }
} }
} }
@ -1597,12 +1597,11 @@ impl LocalSnapshot {
pub(crate) fn repo_for_metadata( pub(crate) fn repo_for_metadata(
&self, &self,
path: &Path, path: &Path,
) -> Option<(ProjectEntryId, Arc<Mutex<dyn GitRepository>>)> { ) -> Option<(&ProjectEntryId, &LocalRepositoryEntry)> {
let (entry_id, local_repo) = self self
.git_repositories .git_repositories
.iter() .iter()
.find(|(_, repo)| repo.in_dot_git(path))?; .find(|(_, repo)| repo.in_dot_git(path))
Some((*entry_id, local_repo.repo_ptr.to_owned()))
} }
#[cfg(test)] #[cfg(test)]
@ -2916,13 +2915,19 @@ impl BackgroundScanner {
.components() .components()
.any(|component| component.as_os_str() == *DOT_GIT) .any(|component| component.as_os_str() == *DOT_GIT)
{ {
let (entry_id, repo_ptr) = {
let (entry_id, repo) = snapshot.repo_for_metadata(&path)?; let (entry_id, repo) = snapshot.repo_for_metadata(&path)?;
if repo.full_scan_id == scan_id {
return None;
}
(*entry_id, repo.repo_ptr.to_owned())
};
let work_dir = snapshot let work_dir = snapshot
.entry_for_id(entry_id) .entry_for_id(entry_id)
.map(|entry| RepositoryWorkDirectory(entry.path.clone()))?; .map(|entry| RepositoryWorkDirectory(entry.path.clone()))?;
let repo = repo.lock(); let repo = repo_ptr.lock();
repo.reload_index(); repo.reload_index();
let branch = repo.branch_name(); let branch = repo.branch_name();
let statuses = repo.worktree_statuses().unwrap_or_default(); let statuses = repo.worktree_statuses().unwrap_or_default();
@ -3950,8 +3955,6 @@ mod tests {
std::fs::remove_file(work_dir.join(B_TXT)).unwrap(); std::fs::remove_file(work_dir.join(B_TXT)).unwrap();
std::fs::remove_dir_all(work_dir.join("c")).unwrap(); std::fs::remove_dir_all(work_dir.join("c")).unwrap();
dbg!(git_status(&repo));
tree.flush_fs_events(cx).await; tree.flush_fs_events(cx).await;
// Check that non-repo behavior is tracked // Check that non-repo behavior is tracked
@ -3959,8 +3962,6 @@ mod tests {
let snapshot = tree.snapshot(); let snapshot = tree.snapshot();
let (_, repo) = snapshot.repository_entries.iter().next().unwrap(); let (_, repo) = snapshot.repository_entries.iter().next().unwrap();
dbg!(&repo.worktree_statuses);
assert_eq!(repo.worktree_statuses.iter().count(), 0); assert_eq!(repo.worktree_statuses.iter().count(), 0);
assert_eq!(repo.worktree_statuses.get(&Path::new(A_TXT).into()), None); assert_eq!(repo.worktree_statuses.get(&Path::new(A_TXT).into()), None);
assert_eq!(repo.worktree_statuses.get(&Path::new(B_TXT).into()), None); assert_eq!(repo.worktree_statuses.get(&Path::new(B_TXT).into()), None);

View file

@ -986,12 +986,12 @@ message Entry {
message RepositoryEntry { message RepositoryEntry {
uint64 work_directory_id = 1; uint64 work_directory_id = 1;
optional string branch = 2; optional string branch = 2;
repeated uint64 removed_statuses = 3; repeated string removed_worktree_repo_paths = 3;
repeated StatusEntry updated_statuses = 4; repeated StatusEntry updated_worktree_statuses = 4;
} }
message StatusEntry { message StatusEntry {
uint64 entry_id = 1; string repo_path = 1;
GitStatus status = 2; GitStatus status = 2;
} }