diff --git a/Cargo.lock b/Cargo.lock index 7468b53741..4e3473b639 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4318,7 +4318,9 @@ dependencies = [ "git2", "lazy_static", "log", + "parking_lot", "pretty_assertions", + "rope", "serde", "serde_json", "smol", @@ -4327,6 +4329,7 @@ dependencies = [ "time", "unindent", "url", + "util", "windows 0.53.0", ] @@ -7375,6 +7378,7 @@ dependencies = [ "db", "editor", "file_icons", + "git", "gpui", "language", "menu", @@ -10988,8 +10992,8 @@ name = "vcs_menu" version = "0.1.0" dependencies = [ "anyhow", - "fs", "fuzzy", + "git", "gpui", "picker", "ui", diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rs index 4370eda090..728c8806fe 100644 --- a/crates/collab/src/tests/integration_tests.rs +++ b/crates/collab/src/tests/integration_tests.rs @@ -9,8 +9,9 @@ use anyhow::{anyhow, Result}; use call::{room, ActiveCall, ParticipantLocation, Room}; use client::{User, RECEIVE_TIMEOUT}; use collections::{HashMap, HashSet}; -use fs::{repository::GitFileStatus, FakeFs, Fs as _, RemoveOptions}; +use fs::{FakeFs, Fs as _, RemoveOptions}; use futures::{channel::mpsc, StreamExt as _}; +use git::repository::GitFileStatus; use gpui::{ px, size, AppContext, BackgroundExecutor, BorrowAppContext, Model, Modifiers, MouseButton, MouseDownEvent, TestAppContext, diff --git a/crates/collab/src/tests/random_project_collaboration_tests.rs b/crates/collab/src/tests/random_project_collaboration_tests.rs index 8674069dff..e06b79d5a8 100644 --- a/crates/collab/src/tests/random_project_collaboration_tests.rs +++ b/crates/collab/src/tests/random_project_collaboration_tests.rs @@ -5,8 +5,9 @@ use async_trait::async_trait; use call::ActiveCall; use collections::{BTreeMap, HashMap}; use editor::Bias; -use fs::{repository::GitFileStatus, FakeFs, Fs as _}; +use fs::{FakeFs, Fs as _}; use futures::StreamExt; +use git::repository::GitFileStatus; use gpui::{BackgroundExecutor, Model, TestAppContext}; use language::{ range_to_lsp, FakeLspAdapter, Language, LanguageConfig, LanguageMatcher, PointUtf16, diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 8cba960c1f..ac3b3e95c1 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -6,6 +6,7 @@ use crate::{ use anyhow::{anyhow, Context as _, Result}; use collections::HashSet; use futures::future::try_join_all; +use git::repository::GitFileStatus; use gpui::{ point, AnyElement, AppContext, AsyncWindowContext, Context, Entity, EntityId, EventEmitter, IntoElement, Model, ParentElement, Pixels, SharedString, Styled, Task, View, ViewContext, @@ -15,7 +16,6 @@ use language::{ proto::serialize_anchor as serialize_text_anchor, Bias, Buffer, CharKind, OffsetRangeExt, Point, SelectionGoal, }; -use project::repository::GitFileStatus; use project::{search::SearchQuery, FormatTrigger, Item as _, Project, ProjectPath}; use rpc::proto::{self, update_view, PeerId}; use settings::Settings; diff --git a/crates/fs/Cargo.toml b/crates/fs/Cargo.toml index 9d1ec496f5..83acc7f0f9 100644 --- a/crates/fs/Cargo.toml +++ b/crates/fs/Cargo.toml @@ -16,7 +16,6 @@ collections.workspace = true rope.workspace = true text.workspace = true util.workspace = true -sum_tree.workspace = true anyhow.workspace = true async-tar.workspace = true @@ -29,9 +28,7 @@ smol.workspace = true git.workspace = true git2.workspace = true serde.workspace = true -serde_derive.workspace = true serde_json.workspace = true -log.workspace = true libc = "0.2" time.workspace = true @@ -50,4 +47,4 @@ windows.workspace = true gpui = { workspace = true, features = ["test-support"] } [features] -test-support = ["gpui/test-support"] +test-support = ["gpui/test-support", "git/test-support"] diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index 7837ec034d..6748a94b00 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -1,5 +1,3 @@ -pub mod repository; - use anyhow::{anyhow, Result}; #[cfg(unix)] @@ -7,9 +5,9 @@ use std::os::unix::fs::MetadataExt; use async_tar::Archive; use futures::{future::BoxFuture, AsyncRead, Stream, StreamExt}; +use git::repository::{GitRepository, RealGitRepository}; use git2::Repository as LibGitRepository; use parking_lot::Mutex; -use repository::{GitRepository, RealGitRepository}; use rope::Rope; #[cfg(any(test, feature = "test-support"))] use smol::io::AsyncReadExt; @@ -29,7 +27,7 @@ use util::{paths, ResultExt}; #[cfg(any(test, feature = "test-support"))] use collections::{btree_map, BTreeMap}; #[cfg(any(test, feature = "test-support"))] -use repository::{FakeGitRepositoryState, GitFileStatus}; +use git::repository::{FakeGitRepositoryState, GitFileStatus}; #[cfg(any(test, feature = "test-support"))] use std::ffi::OsStr; @@ -525,7 +523,7 @@ enum FakeFsEntry { inode: u64, mtime: SystemTime, entries: BTreeMap>>, - git_repo_state: Option>>, + git_repo_state: Option>>, }, Symlink { target: PathBuf, @@ -1417,7 +1415,7 @@ impl Fs for FakeFs { let state = git_repo_state .get_or_insert_with(|| Arc::new(Mutex::new(FakeGitRepositoryState::default()))) .clone(); - Some(repository::FakeGitRepository::open(state)) + Some(git::repository::FakeGitRepository::open(state)) } else { None } diff --git a/crates/git/Cargo.toml b/crates/git/Cargo.toml index c839ee069e..26585e2c0e 100644 --- a/crates/git/Cargo.toml +++ b/crates/git/Cargo.toml @@ -24,6 +24,9 @@ text.workspace = true time.workspace = true url.workspace = true serde.workspace = true +rope.workspace = true +util.workspace = true +parking_lot.workspace = true windows.workspace = true [dev-dependencies] diff --git a/crates/git/src/git.rs b/crates/git/src/git.rs index e48c677d97..ddb7f11f5a 100644 --- a/crates/git/src/git.rs +++ b/crates/git/src/git.rs @@ -11,6 +11,7 @@ pub mod blame; pub mod commit; pub mod diff; pub mod permalink; +pub mod repository; lazy_static! { pub static ref DOT_GIT: &'static OsStr = OsStr::new(".git"); diff --git a/crates/fs/src/repository.rs b/crates/git/src/repository.rs similarity index 97% rename from crates/fs/src/repository.rs rename to crates/git/src/repository.rs index e1a23911ab..0b479162e0 100644 --- a/crates/fs/src/repository.rs +++ b/crates/git/src/repository.rs @@ -1,10 +1,10 @@ +use crate::blame::Blame; use anyhow::{Context, Result}; use collections::HashMap; -use git::blame::Blame; use git2::{BranchType, StatusShow}; use parking_lot::Mutex; use rope::Rope; -use serde_derive::{Deserialize, Serialize}; +use serde::{Deserialize, Serialize}; use std::{ cmp::Ordering, path::{Component, Path, PathBuf}, @@ -59,7 +59,7 @@ pub trait GitRepository: Send { fn change_branch(&self, _: &str) -> Result<()>; fn create_branch(&self, _: &str) -> Result<()>; - fn blame(&self, path: &Path, content: Rope) -> Result; + fn blame(&self, path: &Path, content: Rope) -> Result; } impl std::fmt::Debug for dyn GitRepository { @@ -231,7 +231,7 @@ impl GitRepository for RealGitRepository { Ok(()) } - fn blame(&self, path: &Path, content: Rope) -> Result { + fn blame(&self, path: &Path, content: Rope) -> Result { let working_directory = self .repository .workdir() @@ -240,7 +240,7 @@ impl GitRepository for RealGitRepository { const REMOTE_NAME: &str = "origin"; let remote_url = self.remote_url(REMOTE_NAME); - git::blame::Blame::for_path( + crate::blame::Blame::for_path( &self.git_binary_path, working_directory, path, @@ -358,7 +358,7 @@ impl GitRepository for FakeGitRepository { Ok(()) } - fn blame(&self, path: &Path, _content: Rope) -> Result { + fn blame(&self, path: &Path, _content: Rope) -> Result { let state = self.state.lock(); state .blames diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 04af41ba71..6113ea8e92 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -21,7 +21,6 @@ use clock::ReplicaId; use collections::{hash_map, BTreeMap, HashMap, HashSet, VecDeque}; use copilot::Copilot; use debounced_delay::DebouncedDelay; -use fs::repository::GitRepository; use futures::{ channel::{ mpsc::{self, UnboundedReceiver}, @@ -32,7 +31,7 @@ use futures::{ stream::FuturesUnordered, AsyncWriteExt, Future, FutureExt, StreamExt, TryFutureExt, }; -use git::blame::Blame; +use git::{blame::Blame, repository::GitRepository}; use globset::{Glob, GlobSet, GlobSetBuilder}; use gpui::{ AnyModel, AppContext, AsyncAppContext, BackgroundExecutor, BorrowAppContext, Context, Entity, diff --git a/crates/project_panel/Cargo.toml b/crates/project_panel/Cargo.toml index b7b8f97313..92912bf007 100644 --- a/crates/project_panel/Cargo.toml +++ b/crates/project_panel/Cargo.toml @@ -18,6 +18,7 @@ collections.workspace = true db.workspace = true editor.workspace = true file_icons.workspace = true +git.workspace = true gpui.workspace = true menu.workspace = true pretty_assertions.workspace = true diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 89f3c7e8d9..b08f46b7e7 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -8,6 +8,7 @@ use file_icons::FileIcons; use anyhow::{anyhow, Result}; use collections::{hash_map, HashMap}; +use git::repository::GitFileStatus; use gpui::{ actions, anchored, deferred, div, impl_actions, px, uniform_list, Action, AppContext, AssetSource, AsyncWindowContext, ClipboardItem, DismissEvent, Div, EventEmitter, FocusHandle, @@ -16,10 +17,7 @@ use gpui::{ UniformListScrollHandle, View, ViewContext, VisualContext as _, WeakView, WindowContext, }; use menu::{Confirm, SelectNext, SelectPrev}; -use project::{ - repository::GitFileStatus, Entry, EntryKind, Fs, Project, ProjectEntryId, ProjectPath, - Worktree, WorktreeId, -}; +use project::{Entry, EntryKind, Fs, Project, ProjectEntryId, ProjectPath, Worktree, WorktreeId}; use project_panel_settings::{ProjectPanelDockPosition, ProjectPanelSettings}; use serde::{Deserialize, Serialize}; use std::{ diff --git a/crates/vcs_menu/Cargo.toml b/crates/vcs_menu/Cargo.toml index 786e2ee6fc..75dcad83df 100644 --- a/crates/vcs_menu/Cargo.toml +++ b/crates/vcs_menu/Cargo.toml @@ -10,8 +10,8 @@ workspace = true [dependencies] anyhow.workspace = true -fs.workspace = true fuzzy.workspace = true +git.workspace = true gpui.workspace = true picker.workspace = true ui.workspace = true diff --git a/crates/vcs_menu/src/lib.rs b/crates/vcs_menu/src/lib.rs index affd27de58..9df2bafda8 100644 --- a/crates/vcs_menu/src/lib.rs +++ b/crates/vcs_menu/src/lib.rs @@ -1,6 +1,6 @@ use anyhow::{anyhow, bail, Result}; -use fs::repository::Branch; use fuzzy::{StringMatch, StringMatchCandidate}; +use git::repository::Branch; use gpui::{ actions, rems, AnyElement, AppContext, DismissEvent, Element, EventEmitter, FocusHandle, FocusableView, InteractiveElement, IntoElement, ParentElement, Render, SharedString, Styled, diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 72e1b049be..5e4556f3d2 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -8,11 +8,8 @@ use anyhow::{anyhow, Context as _, Result}; use client::{proto, Client}; use clock::ReplicaId; use collections::{HashMap, HashSet, VecDeque}; +use fs::Fs; use fs::{copy_recursive, RemoveOptions}; -use fs::{ - repository::{GitFileStatus, GitRepository, RepoPath}, - Fs, -}; use futures::{ channel::{ mpsc::{self, UnboundedSender}, @@ -23,7 +20,10 @@ use futures::{ FutureExt as _, Stream, StreamExt, }; use fuzzy::CharBag; -use git::{DOT_GIT, GITIGNORE}; +use git::{ + repository::{GitFileStatus, GitRepository, RepoPath}, + DOT_GIT, GITIGNORE, +}; use gpui::{ AppContext, AsyncAppContext, BackgroundExecutor, Context, EventEmitter, Model, ModelContext, Task, diff --git a/crates/worktree/src/worktree_tests.rs b/crates/worktree/src/worktree_tests.rs index 5efee216b6..4067d03908 100644 --- a/crates/worktree/src/worktree_tests.rs +++ b/crates/worktree/src/worktree_tests.rs @@ -5,8 +5,8 @@ use crate::{ use anyhow::Result; use client::Client; use clock::FakeSystemClock; -use fs::{repository::GitFileStatus, FakeFs, Fs, RealFs, RemoveOptions}; -use git::GITIGNORE; +use fs::{FakeFs, Fs, RealFs, RemoveOptions}; +use git::{repository::GitFileStatus, GITIGNORE}; use gpui::{BorrowAppContext, ModelContext, Task, TestAppContext}; use parking_lot::Mutex; use postage::stream::Stream;