From 17925ed5631f86a8564c885172cd9521012b2edc Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 6 Oct 2023 13:14:53 -0700 Subject: [PATCH] Remove unnecessary dependencies on client and rpc --- Cargo.lock | 1 - crates/fs/Cargo.toml | 1 - crates/fs/src/repository.rs | 20 +------------------- crates/language/Cargo.toml | 1 - crates/project/src/worktree.rs | 22 ++++++++++++++++++++-- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c57548057d..1b6583f067 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2832,7 +2832,6 @@ dependencies = [ "parking_lot 0.11.2", "regex", "rope", - "rpc", "serde", "serde_derive", "serde_json", diff --git a/crates/fs/Cargo.toml b/crates/fs/Cargo.toml index 441ce6f9c7..11a34bcecb 100644 --- a/crates/fs/Cargo.toml +++ b/crates/fs/Cargo.toml @@ -13,7 +13,6 @@ rope = { path = "../rope" } text = { path = "../text" } util = { path = "../util" } sum_tree = { path = "../sum_tree" } -rpc = { path = "../rpc" } anyhow.workspace = true async-trait.workspace = true diff --git a/crates/fs/src/repository.rs b/crates/fs/src/repository.rs index 2b2aebe679..4637a7f754 100644 --- a/crates/fs/src/repository.rs +++ b/crates/fs/src/repository.rs @@ -2,7 +2,6 @@ use anyhow::Result; use collections::HashMap; use git2::{BranchType, StatusShow}; use parking_lot::Mutex; -use rpc::proto; use serde_derive::{Deserialize, Serialize}; use std::{ cmp::Ordering, @@ -23,6 +22,7 @@ pub struct Branch { /// Timestamp of most recent commit, normalized to Unix Epoch format. pub unix_timestamp: Option, } + #[async_trait::async_trait] pub trait GitRepository: Send { fn reload_index(&self); @@ -358,24 +358,6 @@ impl GitFileStatus { } } } - - pub fn from_proto(git_status: Option) -> Option { - git_status.and_then(|status| { - proto::GitStatus::from_i32(status).map(|status| match status { - proto::GitStatus::Added => GitFileStatus::Added, - proto::GitStatus::Modified => GitFileStatus::Modified, - proto::GitStatus::Conflict => GitFileStatus::Conflict, - }) - }) - } - - pub fn to_proto(self) -> i32 { - match self { - GitFileStatus::Added => proto::GitStatus::Added as i32, - GitFileStatus::Modified => proto::GitStatus::Modified as i32, - GitFileStatus::Conflict => proto::GitStatus::Conflict as i32, - } - } } #[derive(Clone, Debug, Ord, Hash, PartialOrd, Eq, PartialEq)] diff --git a/crates/language/Cargo.toml b/crates/language/Cargo.toml index 4771fc7083..cf468020ce 100644 --- a/crates/language/Cargo.toml +++ b/crates/language/Cargo.toml @@ -22,7 +22,6 @@ test-support = [ ] [dependencies] -client = { path = "../client" } clock = { path = "../clock" } collections = { path = "../collections" } fuzzy = { path = "../fuzzy" } diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 2de3671033..a38e43cd87 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -4310,7 +4310,7 @@ impl<'a> From<&'a Entry> for proto::Entry { is_symlink: entry.is_symlink, is_ignored: entry.is_ignored, is_external: entry.is_external, - git_status: entry.git_status.map(|status| status.to_proto()), + git_status: entry.git_status.map(git_status_to_proto), } } } @@ -4337,7 +4337,7 @@ impl<'a> TryFrom<(&'a CharBag, proto::Entry)> for Entry { is_symlink: entry.is_symlink, is_ignored: entry.is_ignored, is_external: entry.is_external, - git_status: GitFileStatus::from_proto(entry.git_status), + git_status: git_status_from_proto(entry.git_status), }) } else { Err(anyhow!( @@ -4366,3 +4366,21 @@ fn combine_git_statuses( unstaged } } + +fn git_status_from_proto(git_status: Option) -> Option { + git_status.and_then(|status| { + proto::GitStatus::from_i32(status).map(|status| match status { + proto::GitStatus::Added => GitFileStatus::Added, + proto::GitStatus::Modified => GitFileStatus::Modified, + proto::GitStatus::Conflict => GitFileStatus::Conflict, + }) + }) +} + +fn git_status_to_proto(status: GitFileStatus) -> i32 { + match status { + GitFileStatus::Added => proto::GitStatus::Added as i32, + GitFileStatus::Modified => proto::GitStatus::Modified as i32, + GitFileStatus::Conflict => proto::GitStatus::Conflict as i32, + } +}