Finish removing git repository state and scanning logic from worktrees (#27568)
This PR completes the process of moving git repository state storage and scanning logic from the worktree crate to `project::git_store`. Release Notes: - N/A --------- Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com> Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
parent
8f25251faf
commit
e7290df02b
39 changed files with 3121 additions and 3529 deletions
|
@ -1937,7 +1937,7 @@ message Entry {
|
|||
}
|
||||
|
||||
message RepositoryEntry {
|
||||
uint64 work_directory_id = 1;
|
||||
uint64 repository_id = 1;
|
||||
reserved 2;
|
||||
repeated StatusEntry updated_statuses = 3;
|
||||
repeated string removed_statuses = 4;
|
||||
|
@ -1955,6 +1955,7 @@ message UpdateRepository {
|
|||
repeated string removed_statuses = 7;
|
||||
repeated string current_merge_conflicts = 8;
|
||||
uint64 scan_id = 9;
|
||||
bool is_last_update = 10;
|
||||
}
|
||||
|
||||
message RemoveRepository {
|
||||
|
@ -2247,7 +2248,7 @@ message OpenUncommittedDiffResponse {
|
|||
message SetIndexText {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
string path = 4;
|
||||
optional string text = 5;
|
||||
}
|
||||
|
@ -3356,7 +3357,7 @@ message GetPanicFiles {
|
|||
message GitShow {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
string commit = 4;
|
||||
}
|
||||
|
||||
|
@ -3371,7 +3372,7 @@ message GitCommitDetails {
|
|||
message LoadCommitDiff {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
string commit = 4;
|
||||
}
|
||||
|
||||
|
@ -3388,7 +3389,7 @@ message CommitFile {
|
|||
message GitReset {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
string commit = 4;
|
||||
ResetMode mode = 5;
|
||||
enum ResetMode {
|
||||
|
@ -3400,7 +3401,7 @@ message GitReset {
|
|||
message GitCheckoutFiles {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
string commit = 4;
|
||||
repeated string paths = 5;
|
||||
}
|
||||
|
@ -3455,21 +3456,21 @@ message RegisterBufferWithLanguageServers{
|
|||
message Stage {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
repeated string paths = 4;
|
||||
}
|
||||
|
||||
message Unstage {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
repeated string paths = 4;
|
||||
}
|
||||
|
||||
message Commit {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
optional string name = 4;
|
||||
optional string email = 5;
|
||||
string message = 6;
|
||||
|
@ -3478,13 +3479,13 @@ message Commit {
|
|||
message OpenCommitMessageBuffer {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
}
|
||||
|
||||
message Push {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
string remote_name = 4;
|
||||
string branch_name = 5;
|
||||
optional PushOptions options = 6;
|
||||
|
@ -3499,14 +3500,14 @@ message Push {
|
|||
message Fetch {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
uint64 askpass_id = 4;
|
||||
}
|
||||
|
||||
message GetRemotes {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
optional string branch_name = 4;
|
||||
}
|
||||
|
||||
|
@ -3521,7 +3522,7 @@ message GetRemotesResponse {
|
|||
message Pull {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
string remote_name = 4;
|
||||
string branch_name = 5;
|
||||
uint64 askpass_id = 6;
|
||||
|
@ -3535,7 +3536,7 @@ message RemoteMessageResponse {
|
|||
message AskPassRequest {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
uint64 askpass_id = 4;
|
||||
string prompt = 5;
|
||||
}
|
||||
|
@ -3547,27 +3548,27 @@ message AskPassResponse {
|
|||
message GitGetBranches {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
}
|
||||
|
||||
message GitCreateBranch {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
string branch_name = 4;
|
||||
}
|
||||
|
||||
message GitChangeBranch {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
string branch_name = 4;
|
||||
}
|
||||
|
||||
message CheckForPushedCommits {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
}
|
||||
|
||||
message CheckForPushedCommitsResponse {
|
||||
|
@ -3577,7 +3578,7 @@ message CheckForPushedCommitsResponse {
|
|||
message GitDiff {
|
||||
uint64 project_id = 1;
|
||||
reserved 2;
|
||||
uint64 work_directory_id = 3;
|
||||
uint64 repository_id = 3;
|
||||
DiffType diff_type = 4;
|
||||
|
||||
enum DiffType {
|
||||
|
|
|
@ -834,7 +834,7 @@ pub fn split_worktree_update(mut message: UpdateWorktree) -> impl Iterator<Item
|
|||
let removed_statuses_limit = cmp::min(repo.removed_statuses.len(), limit);
|
||||
|
||||
updated_repositories.push(RepositoryEntry {
|
||||
work_directory_id: repo.work_directory_id,
|
||||
repository_id: repo.repository_id,
|
||||
branch_summary: repo.branch_summary.clone(),
|
||||
updated_statuses: repo
|
||||
.updated_statuses
|
||||
|
@ -885,26 +885,34 @@ pub fn split_repository_update(
|
|||
) -> impl Iterator<Item = UpdateRepository> {
|
||||
let mut updated_statuses_iter = mem::take(&mut update.updated_statuses).into_iter().fuse();
|
||||
let mut removed_statuses_iter = mem::take(&mut update.removed_statuses).into_iter().fuse();
|
||||
let mut is_first = true;
|
||||
std::iter::from_fn(move || {
|
||||
let updated_statuses = updated_statuses_iter
|
||||
.by_ref()
|
||||
.take(MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE)
|
||||
.collect::<Vec<_>>();
|
||||
let removed_statuses = removed_statuses_iter
|
||||
.by_ref()
|
||||
.take(MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE)
|
||||
.collect::<Vec<_>>();
|
||||
if updated_statuses.is_empty() && removed_statuses.is_empty() && !is_first {
|
||||
return None;
|
||||
std::iter::from_fn({
|
||||
let update = update.clone();
|
||||
move || {
|
||||
let updated_statuses = updated_statuses_iter
|
||||
.by_ref()
|
||||
.take(MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE)
|
||||
.collect::<Vec<_>>();
|
||||
let removed_statuses = removed_statuses_iter
|
||||
.by_ref()
|
||||
.take(MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE)
|
||||
.collect::<Vec<_>>();
|
||||
if updated_statuses.is_empty() && removed_statuses.is_empty() {
|
||||
return None;
|
||||
}
|
||||
Some(UpdateRepository {
|
||||
updated_statuses,
|
||||
removed_statuses,
|
||||
is_last_update: false,
|
||||
..update.clone()
|
||||
})
|
||||
}
|
||||
is_first = false;
|
||||
Some(UpdateRepository {
|
||||
updated_statuses,
|
||||
removed_statuses,
|
||||
..update.clone()
|
||||
})
|
||||
})
|
||||
.chain([UpdateRepository {
|
||||
updated_statuses: Vec::new(),
|
||||
removed_statuses: Vec::new(),
|
||||
is_last_update: true,
|
||||
..update
|
||||
}])
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue