Migrate most callers of git-related worktree APIs to use the GitStore (#27225)
This is a pure refactoring PR that goes through all the git-related APIs exposed by the worktree crate and minimizes their use outside that crate, migrating callers of those APIs to read from the GitStore instead. This is to prepare for evacuating git repository state from worktrees and making the GitStore the new source of truth. Other drive-by changes: - `project::git` is now `project::git_store`, for consistency with the other project stores - the project panel's test module has been split into its own file Release Notes: - N/A --------- Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
parent
9134630841
commit
cf7d639fbc
26 changed files with 6480 additions and 6429 deletions
|
@ -2895,9 +2895,10 @@ async fn test_git_branch_name(
|
|||
let worktrees = project.visible_worktrees(cx).collect::<Vec<_>>();
|
||||
assert_eq!(worktrees.len(), 1);
|
||||
let worktree = worktrees[0].clone();
|
||||
let root_entry = worktree.read(cx).snapshot().root_git_entry().unwrap();
|
||||
let snapshot = worktree.read(cx).snapshot();
|
||||
let repo = snapshot.repositories().first().unwrap();
|
||||
assert_eq!(
|
||||
root_entry.branch().map(|branch| branch.name.to_string()),
|
||||
repo.branch().map(|branch| branch.name.to_string()),
|
||||
branch_name
|
||||
);
|
||||
}
|
||||
|
@ -6771,7 +6772,7 @@ async fn test_remote_git_branches(
|
|||
.map(ToString::to_string)
|
||||
.collect::<HashSet<_>>();
|
||||
|
||||
let (project_a, worktree_id) = client_a.build_local_project("/project", cx_a).await;
|
||||
let (project_a, _) = client_a.build_local_project("/project", cx_a).await;
|
||||
|
||||
let project_id = active_call_a
|
||||
.update(cx_a, |call, cx| call.share_project(project_a.clone(), cx))
|
||||
|
@ -6784,8 +6785,6 @@ async fn test_remote_git_branches(
|
|||
|
||||
let repo_b = cx_b.update(|cx| project_b.read(cx).active_repository(cx).unwrap());
|
||||
|
||||
let root_path = ProjectPath::root_path(worktree_id);
|
||||
|
||||
let branches_b = cx_b
|
||||
.update(|cx| repo_b.update(cx, |repository, _| repository.branches()))
|
||||
.await
|
||||
|
@ -6810,11 +6809,15 @@ async fn test_remote_git_branches(
|
|||
|
||||
let host_branch = cx_a.update(|cx| {
|
||||
project_a.update(cx, |project, cx| {
|
||||
project.worktree_store().update(cx, |worktree_store, cx| {
|
||||
worktree_store
|
||||
.current_branch(root_path.clone(), cx)
|
||||
.unwrap()
|
||||
})
|
||||
project
|
||||
.repositories(cx)
|
||||
.values()
|
||||
.next()
|
||||
.unwrap()
|
||||
.read(cx)
|
||||
.current_branch()
|
||||
.unwrap()
|
||||
.clone()
|
||||
})
|
||||
});
|
||||
|
||||
|
@ -6843,9 +6846,15 @@ async fn test_remote_git_branches(
|
|||
|
||||
let host_branch = cx_a.update(|cx| {
|
||||
project_a.update(cx, |project, cx| {
|
||||
project.worktree_store().update(cx, |worktree_store, cx| {
|
||||
worktree_store.current_branch(root_path, cx).unwrap()
|
||||
})
|
||||
project
|
||||
.repositories(cx)
|
||||
.values()
|
||||
.next()
|
||||
.unwrap()
|
||||
.read(cx)
|
||||
.current_branch()
|
||||
.unwrap()
|
||||
.clone()
|
||||
})
|
||||
});
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ async fn test_ssh_collaboration_git_branches(
|
|||
});
|
||||
|
||||
let client_ssh = SshRemoteClient::fake_client(opts, cx_a).await;
|
||||
let (project_a, worktree_id) = client_a
|
||||
let (project_a, _) = client_a
|
||||
.build_ssh_project("/project", client_ssh, cx_a)
|
||||
.await;
|
||||
|
||||
|
@ -277,7 +277,6 @@ async fn test_ssh_collaboration_git_branches(
|
|||
executor.run_until_parked();
|
||||
|
||||
let repo_b = cx_b.update(|cx| project_b.read(cx).active_repository(cx).unwrap());
|
||||
let root_path = ProjectPath::root_path(worktree_id);
|
||||
|
||||
let branches_b = cx_b
|
||||
.update(|cx| repo_b.read(cx).branches())
|
||||
|
@ -303,13 +302,17 @@ async fn test_ssh_collaboration_git_branches(
|
|||
|
||||
let server_branch = server_cx.update(|cx| {
|
||||
headless_project.update(cx, |headless_project, cx| {
|
||||
headless_project
|
||||
.worktree_store
|
||||
.update(cx, |worktree_store, cx| {
|
||||
worktree_store
|
||||
.current_branch(root_path.clone(), cx)
|
||||
.unwrap()
|
||||
})
|
||||
headless_project.git_store.update(cx, |git_store, cx| {
|
||||
git_store
|
||||
.repositories()
|
||||
.values()
|
||||
.next()
|
||||
.unwrap()
|
||||
.read(cx)
|
||||
.current_branch()
|
||||
.unwrap()
|
||||
.clone()
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
|
@ -338,11 +341,17 @@ async fn test_ssh_collaboration_git_branches(
|
|||
|
||||
let server_branch = server_cx.update(|cx| {
|
||||
headless_project.update(cx, |headless_project, cx| {
|
||||
headless_project
|
||||
.worktree_store
|
||||
.update(cx, |worktree_store, cx| {
|
||||
worktree_store.current_branch(root_path, cx).unwrap()
|
||||
})
|
||||
headless_project.git_store.update(cx, |git_store, cx| {
|
||||
git_store
|
||||
.repositories()
|
||||
.values()
|
||||
.next()
|
||||
.unwrap()
|
||||
.read(cx)
|
||||
.current_branch()
|
||||
.unwrap()
|
||||
.clone()
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue