Move git state to Project (#23208)
This restores its visibility outside of git_ui, which we'll need soon, while preserving its per-project character. Release Notes: - N/A
This commit is contained in:
parent
614eaec278
commit
b7726238ad
10 changed files with 363 additions and 317 deletions
|
@ -2,6 +2,7 @@ pub mod buffer_store;
|
|||
mod color_extractor;
|
||||
pub mod connection_manager;
|
||||
pub mod debounced_delay;
|
||||
pub mod git;
|
||||
pub mod image_store;
|
||||
pub mod lsp_command;
|
||||
pub mod lsp_ext_command;
|
||||
|
@ -24,6 +25,7 @@ pub use environment::EnvironmentErrorMessage;
|
|||
pub mod search_history;
|
||||
mod yarn;
|
||||
|
||||
use crate::git::GitState;
|
||||
use anyhow::{anyhow, Context as _, Result};
|
||||
use buffer_store::{BufferChangeSet, BufferStore, BufferStoreEvent};
|
||||
use client::{proto, Client, Collaborator, PendingEntitySubscription, TypedEnvelope, UserStore};
|
||||
|
@ -39,7 +41,11 @@ use futures::{
|
|||
pub use image_store::{ImageItem, ImageStore};
|
||||
use image_store::{ImageItemEvent, ImageStoreEvent};
|
||||
|
||||
use git::{blame::Blame, repository::GitRepository, status::FileStatus};
|
||||
use ::git::{
|
||||
blame::Blame,
|
||||
repository::{Branch, GitRepository},
|
||||
status::FileStatus,
|
||||
};
|
||||
use gpui::{
|
||||
AnyModel, AppContext, AsyncAppContext, BorrowAppContext, Context as _, EventEmitter, Hsla,
|
||||
Model, ModelContext, SharedString, Task, WeakModel, WindowContext,
|
||||
|
@ -148,6 +154,7 @@ pub struct Project {
|
|||
fs: Arc<dyn Fs>,
|
||||
ssh_client: Option<Model<SshRemoteClient>>,
|
||||
client_state: ProjectClientState,
|
||||
git_state: Option<Model<GitState>>,
|
||||
collaborators: HashMap<proto::PeerId, Collaborator>,
|
||||
client_subscriptions: Vec<client::Subscription>,
|
||||
worktree_store: Model<WorktreeStore>,
|
||||
|
@ -685,6 +692,9 @@ impl Project {
|
|||
cx,
|
||||
)
|
||||
});
|
||||
|
||||
let git_state = Some(cx.new_model(|cx| GitState::new(cx)));
|
||||
|
||||
cx.subscribe(&lsp_store, Self::on_lsp_store_event).detach();
|
||||
|
||||
Self {
|
||||
|
@ -696,6 +706,7 @@ impl Project {
|
|||
lsp_store,
|
||||
join_project_response_message_id: 0,
|
||||
client_state: ProjectClientState::Local,
|
||||
git_state,
|
||||
client_subscriptions: Vec::new(),
|
||||
_subscriptions: vec![cx.on_release(Self::release)],
|
||||
active_entry: None,
|
||||
|
@ -814,6 +825,7 @@ impl Project {
|
|||
lsp_store,
|
||||
join_project_response_message_id: 0,
|
||||
client_state: ProjectClientState::Local,
|
||||
git_state: None,
|
||||
client_subscriptions: Vec::new(),
|
||||
_subscriptions: vec![
|
||||
cx.on_release(Self::release),
|
||||
|
@ -1045,6 +1057,7 @@ impl Project {
|
|||
remote_id,
|
||||
replica_id,
|
||||
},
|
||||
git_state: None,
|
||||
buffers_needing_diff: Default::default(),
|
||||
git_diff_debouncer: DebouncedDelay::new(),
|
||||
terminals: Terminals {
|
||||
|
@ -3534,7 +3547,7 @@ impl Project {
|
|||
&self,
|
||||
project_path: ProjectPath,
|
||||
cx: &AppContext,
|
||||
) -> Task<Result<Vec<git::repository::Branch>>> {
|
||||
) -> Task<Result<Vec<Branch>>> {
|
||||
self.worktree_store().read(cx).branches(project_path, cx)
|
||||
}
|
||||
|
||||
|
@ -4154,6 +4167,10 @@ impl Project {
|
|||
pub fn buffer_store(&self) -> &Model<BufferStore> {
|
||||
&self.buffer_store
|
||||
}
|
||||
|
||||
pub fn git_state(&self) -> Option<&Model<GitState>> {
|
||||
self.git_state.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
fn deserialize_code_actions(code_actions: &HashMap<String, bool>) -> Vec<lsp::CodeActionKind> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue