Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Finished RepositoryEntry refactoring, smoke tests passing
Mikayla Maki270147d20c8c
diff --git a/crates/collab/migrations.sqlite/20221109000000_test_schema.sql b/crates/collab/migrations.sqlite/20221109000000_test_schema.sqlindex c77d13c898a..684b6bffe0b 100644--- a/crates/collab/migrations.sqlite/20221109000000_test_schema.sql+++ b/crates/collab/migrations.sqlite/20221109000000_test_schema.sql@@ -85,14 +85,13 @@ CREATE INDEX "index_worktree_entries_on_project_id_and_worktree_id" ON "worktreeCREATE TABLE "worktree_repositories" ("project_id" INTEGER NOT NULL,"worktree_id" INTEGER NOT NULL,- "dot_git_entry_id" INTEGER NOT NULL,+ "work_directory_id" INTEGER NOT NULL,"scan_id" INTEGER NOT NULL,"branch" VARCHAR,- "work_directory_path" VARCHAR NOT NULL,"is_deleted" BOOL NOT NULL,- PRIMARY KEY(project_id, worktree_id, dot_git_entry_id),+ PRIMARY KEY(project_id, worktree_id, work_directory_id),FOREIGN KEY(project_id, worktree_id) REFERENCES worktrees (project_id, id) ON DELETE CASCADE,- FOREIGN KEY(project_id, worktree_id, dot_git_entry_id) REFERENCES worktree_entries (project_id, worktree_id, id) ON DELETE CASCADE+ FOREIGN KEY(project_id, worktree_id, work_directory_id) REFERENCES worktree_entries (project_id, worktree_id, id) ON DELETE CASCADE);CREATE INDEX "index_worktree_repositories_on_project_id" ON "worktree_repositories" ("project_id");CREATE INDEX "index_worktree_repositories_on_project_id_and_worktree_id" ON "worktree_repositories" ("project_id", "worktree_id");diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rsindex 39f8266978c..23935904d3a 100644--- a/crates/collab/src/rpc.rs+++ b/crates/collab/src/rpc.rs@@ -1063,9 +1063,8 @@ async fn rejoin_room(removed_entries: worktree.removed_entries,scan_id: worktree.scan_id,is_last_update: worktree.completed_scan_id == worktree.scan_id,- //TODO repo- updated_repositories: vec![],- removed_repositories: vec![],+ updated_repositories: worktree.updated_repositories,+ removed_repositories: worktree.removed_repositories,};for update in proto::split_worktree_update(message, MAX_CHUNK_SIZE) {session.peer.send(session.connection_id, update.clone())?;diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rsindex 5b42257f0b7..12388dfb957 100644--- a/crates/project/src/worktree.rs+++ b/crates/project/src/worktree.rs@@ -1422,10 +1422,11 @@ impl Snapshot {scan_id: repository.scan_id as usize,branch: repository.branch.map(Into::into),};- // TODO: Double check this logicif let Some(entry) = self.entry_for_id(repository.work_directory_id()) {self.repository_entries.insert(RepositoryWorkDirectory(entry.path.clone()), repository)+ } else {+ log::error!("no work directory entry for repository {:?}", repository)}}@@ -2528,23 +2529,21 @@ impl BackgroundScanner {let mut snapshot = self.snapshot.lock();let mut git_repositories = mem::take(&mut snapshot.git_repositories);- git_repositories.retain(|project_entry_id, _| {+ git_repositories.retain(|work_directory_id, _| {snapshot- .entry_for_id(*project_entry_id)- .map_or(false, |entry| entry.path.file_name() == Some(&DOT_GIT))+ .entry_for_id(*work_directory_id)+ .map_or(false, |entry| {+ snapshot.entry_for_path(entry.path.join(*DOT_GIT)).is_some()+ })});snapshot.git_repositories = git_repositories;let mut git_repository_entries = mem::take(&mut snapshot.snapshot.repository_entries);git_repository_entries.retain(|_, entry| {- entry- .work_directory(&snapshot)- .map(|directory| {- snapshot- .entry_for_path((directory.as_ref()).join(".git"))- .is_some()- })- .unwrap_or(false)+ snapshot+ .git_repositories+ .get(&entry.work_directory.0)+ .is_some()});snapshot.snapshot.repository_entries = git_repository_entries;