Finished RepositoryEntry refactoring, smoke tests passing
co-authored-by: Max <max@zed.dev>
This commit is contained in:
parent
53569ece03
commit
270147d20c
3 changed files with 16 additions and 19 deletions
|
@ -85,14 +85,13 @@ CREATE INDEX "index_worktree_entries_on_project_id_and_worktree_id" ON "worktree
|
|||
CREATE 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");
|
||||
|
|
|
@ -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())?;
|
||||
|
|
|
@ -1422,10 +1422,11 @@ impl Snapshot {
|
|||
scan_id: repository.scan_id as usize,
|
||||
branch: repository.branch.map(Into::into),
|
||||
};
|
||||
// TODO: Double check this logic
|
||||
if 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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue