Move buffer diff storage from BufferStore
to GitStore
(#26795)
Release Notes: - N/A --------- Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com> Co-authored-by: max <max@zed.dev>
This commit is contained in:
parent
3d1ae68f83
commit
011f823f33
13 changed files with 1395 additions and 1279 deletions
|
@ -29,6 +29,12 @@ impl std::fmt::Display for ChannelId {
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
|
||||||
pub struct ProjectId(pub u64);
|
pub struct ProjectId(pub u64);
|
||||||
|
|
||||||
|
impl ProjectId {
|
||||||
|
pub fn to_proto(&self) -> u64 {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, serde::Serialize, serde::Deserialize,
|
Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, serde::Serialize, serde::Deserialize,
|
||||||
)]
|
)]
|
||||||
|
|
|
@ -1337,7 +1337,7 @@ impl RandomizedTest for ProjectCollaborationTest {
|
||||||
|
|
||||||
let host_diff_base = host_project.read_with(host_cx, |project, cx| {
|
let host_diff_base = host_project.read_with(host_cx, |project, cx| {
|
||||||
project
|
project
|
||||||
.buffer_store()
|
.git_store()
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.get_unstaged_diff(host_buffer.read(cx).remote_id(), cx)
|
.get_unstaged_diff(host_buffer.read(cx).remote_id(), cx)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -1346,7 +1346,7 @@ impl RandomizedTest for ProjectCollaborationTest {
|
||||||
});
|
});
|
||||||
let guest_diff_base = guest_project.read_with(client_cx, |project, cx| {
|
let guest_diff_base = guest_project.read_with(client_cx, |project, cx| {
|
||||||
project
|
project
|
||||||
.buffer_store()
|
.git_store()
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.get_unstaged_diff(guest_buffer.read(cx).remote_id(), cx)
|
.get_unstaged_diff(guest_buffer.read(cx).remote_id(), cx)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
|
@ -52,7 +52,7 @@ use util::ResultExt;
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
use collections::{btree_map, BTreeMap};
|
use collections::{btree_map, BTreeMap};
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
use git::repository::FakeGitRepositoryState;
|
use git::FakeGitRepositoryState;
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
|
@ -885,7 +885,7 @@ enum FakeFsEntry {
|
||||||
mtime: MTime,
|
mtime: MTime,
|
||||||
len: u64,
|
len: u64,
|
||||||
entries: BTreeMap<String, Arc<Mutex<FakeFsEntry>>>,
|
entries: BTreeMap<String, Arc<Mutex<FakeFsEntry>>>,
|
||||||
git_repo_state: Option<Arc<Mutex<git::repository::FakeGitRepositoryState>>>,
|
git_repo_state: Option<Arc<Mutex<git::FakeGitRepositoryState>>>,
|
||||||
},
|
},
|
||||||
Symlink {
|
Symlink {
|
||||||
target: PathBuf,
|
target: PathBuf,
|
||||||
|
@ -2095,7 +2095,7 @@ impl Fs for FakeFs {
|
||||||
)))
|
)))
|
||||||
})
|
})
|
||||||
.clone();
|
.clone();
|
||||||
Some(git::repository::FakeGitRepository::open(state))
|
Some(git::FakeGitRepository::open(state))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,3 +42,4 @@ pretty_assertions.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
text = { workspace = true, features = ["test-support"] }
|
text = { workspace = true, features = ["test-support"] }
|
||||||
unindent.workspace = true
|
unindent.workspace = true
|
||||||
|
gpui = { workspace = true, features = ["test-support"] }
|
||||||
|
|
294
crates/git/src/fake_repository.rs
Normal file
294
crates/git/src/fake_repository.rs
Normal file
|
@ -0,0 +1,294 @@
|
||||||
|
use crate::{
|
||||||
|
blame::Blame,
|
||||||
|
repository::{
|
||||||
|
Branch, CommitDetails, DiffType, GitRepository, PushOptions, Remote, RemoteCommandOutput,
|
||||||
|
RepoPath, ResetMode,
|
||||||
|
},
|
||||||
|
status::{FileStatus, GitStatus},
|
||||||
|
};
|
||||||
|
use anyhow::{Context, Result};
|
||||||
|
use askpass::AskPassSession;
|
||||||
|
use collections::{HashMap, HashSet};
|
||||||
|
use futures::{future::BoxFuture, FutureExt as _};
|
||||||
|
use gpui::{AsyncApp, SharedString};
|
||||||
|
use parking_lot::Mutex;
|
||||||
|
use rope::Rope;
|
||||||
|
use std::{path::PathBuf, sync::Arc};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct FakeGitRepository {
|
||||||
|
state: Arc<Mutex<FakeGitRepositoryState>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct FakeGitRepositoryState {
|
||||||
|
pub path: PathBuf,
|
||||||
|
pub event_emitter: smol::channel::Sender<PathBuf>,
|
||||||
|
pub head_contents: HashMap<RepoPath, String>,
|
||||||
|
pub index_contents: HashMap<RepoPath, String>,
|
||||||
|
pub blames: HashMap<RepoPath, Blame>,
|
||||||
|
pub statuses: HashMap<RepoPath, FileStatus>,
|
||||||
|
pub current_branch_name: Option<String>,
|
||||||
|
pub branches: HashSet<String>,
|
||||||
|
pub simulated_index_write_error_message: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FakeGitRepository {
|
||||||
|
pub fn open(state: Arc<Mutex<FakeGitRepositoryState>>) -> Arc<dyn GitRepository> {
|
||||||
|
Arc::new(FakeGitRepository { state })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FakeGitRepositoryState {
|
||||||
|
pub fn new(path: PathBuf, event_emitter: smol::channel::Sender<PathBuf>) -> Self {
|
||||||
|
FakeGitRepositoryState {
|
||||||
|
path,
|
||||||
|
event_emitter,
|
||||||
|
head_contents: Default::default(),
|
||||||
|
index_contents: Default::default(),
|
||||||
|
blames: Default::default(),
|
||||||
|
statuses: Default::default(),
|
||||||
|
current_branch_name: Default::default(),
|
||||||
|
branches: Default::default(),
|
||||||
|
simulated_index_write_error_message: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GitRepository for FakeGitRepository {
|
||||||
|
fn reload_index(&self) {}
|
||||||
|
|
||||||
|
fn load_index_text(&self, path: RepoPath, _: AsyncApp) -> BoxFuture<Option<String>> {
|
||||||
|
let state = self.state.lock();
|
||||||
|
let content = state.index_contents.get(path.as_ref()).cloned();
|
||||||
|
async { content }.boxed()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn load_committed_text(&self, path: RepoPath, _: AsyncApp) -> BoxFuture<Option<String>> {
|
||||||
|
let state = self.state.lock();
|
||||||
|
let content = state.head_contents.get(path.as_ref()).cloned();
|
||||||
|
async { content }.boxed()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_index_text(
|
||||||
|
&self,
|
||||||
|
path: RepoPath,
|
||||||
|
content: Option<String>,
|
||||||
|
_env: HashMap<String, String>,
|
||||||
|
cx: AsyncApp,
|
||||||
|
) -> BoxFuture<anyhow::Result<()>> {
|
||||||
|
let state = self.state.clone();
|
||||||
|
let executor = cx.background_executor().clone();
|
||||||
|
async move {
|
||||||
|
executor.simulate_random_delay().await;
|
||||||
|
|
||||||
|
let mut state = state.lock();
|
||||||
|
if let Some(message) = state.simulated_index_write_error_message.clone() {
|
||||||
|
return Err(anyhow::anyhow!(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(content) = content {
|
||||||
|
state.index_contents.insert(path.clone(), content);
|
||||||
|
} else {
|
||||||
|
state.index_contents.remove(&path);
|
||||||
|
}
|
||||||
|
state
|
||||||
|
.event_emitter
|
||||||
|
.try_send(state.path.clone())
|
||||||
|
.expect("Dropped repo change event");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
.boxed()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn remote_url(&self, _name: &str) -> Option<String> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn head_sha(&self) -> Option<String> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn merge_head_shas(&self) -> Vec<String> {
|
||||||
|
vec![]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn show(&self, _: String, _: AsyncApp) -> BoxFuture<Result<CommitDetails>> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn reset(&self, _: String, _: ResetMode, _: HashMap<String, String>) -> BoxFuture<Result<()>> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn checkout_files(
|
||||||
|
&self,
|
||||||
|
_: String,
|
||||||
|
_: Vec<RepoPath>,
|
||||||
|
_: HashMap<String, String>,
|
||||||
|
) -> BoxFuture<Result<()>> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn path(&self) -> PathBuf {
|
||||||
|
let state = self.state.lock();
|
||||||
|
state.path.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main_repository_path(&self) -> PathBuf {
|
||||||
|
self.path()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn status(&self, path_prefixes: &[RepoPath]) -> Result<GitStatus> {
|
||||||
|
let state = self.state.lock();
|
||||||
|
|
||||||
|
let mut entries = state
|
||||||
|
.statuses
|
||||||
|
.iter()
|
||||||
|
.filter_map(|(repo_path, status)| {
|
||||||
|
if path_prefixes
|
||||||
|
.iter()
|
||||||
|
.any(|path_prefix| repo_path.0.starts_with(path_prefix))
|
||||||
|
{
|
||||||
|
Some((repo_path.to_owned(), *status))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
entries.sort_unstable_by(|(a, _), (b, _)| a.cmp(&b));
|
||||||
|
|
||||||
|
Ok(GitStatus {
|
||||||
|
entries: entries.into(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn branches(&self) -> BoxFuture<Result<Vec<Branch>>> {
|
||||||
|
let state = self.state.lock();
|
||||||
|
let current_branch = &state.current_branch_name;
|
||||||
|
let result = Ok(state
|
||||||
|
.branches
|
||||||
|
.iter()
|
||||||
|
.map(|branch_name| Branch {
|
||||||
|
is_head: Some(branch_name) == current_branch.as_ref(),
|
||||||
|
name: branch_name.into(),
|
||||||
|
most_recent_commit: None,
|
||||||
|
upstream: None,
|
||||||
|
})
|
||||||
|
.collect());
|
||||||
|
|
||||||
|
async { result }.boxed()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn change_branch(&self, name: String, _: AsyncApp) -> BoxFuture<Result<()>> {
|
||||||
|
let mut state = self.state.lock();
|
||||||
|
state.current_branch_name = Some(name.to_owned());
|
||||||
|
state
|
||||||
|
.event_emitter
|
||||||
|
.try_send(state.path.clone())
|
||||||
|
.expect("Dropped repo change event");
|
||||||
|
async { Ok(()) }.boxed()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_branch(&self, name: String, _: AsyncApp) -> BoxFuture<Result<()>> {
|
||||||
|
let mut state = self.state.lock();
|
||||||
|
state.branches.insert(name.to_owned());
|
||||||
|
state
|
||||||
|
.event_emitter
|
||||||
|
.try_send(state.path.clone())
|
||||||
|
.expect("Dropped repo change event");
|
||||||
|
async { Ok(()) }.boxed()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn blame(
|
||||||
|
&self,
|
||||||
|
path: RepoPath,
|
||||||
|
_content: Rope,
|
||||||
|
_cx: AsyncApp,
|
||||||
|
) -> BoxFuture<Result<crate::blame::Blame>> {
|
||||||
|
let state = self.state.lock();
|
||||||
|
let result = state
|
||||||
|
.blames
|
||||||
|
.get(&path)
|
||||||
|
.with_context(|| format!("failed to get blame for {:?}", path.0))
|
||||||
|
.cloned();
|
||||||
|
async { result }.boxed()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn stage_paths(
|
||||||
|
&self,
|
||||||
|
_paths: Vec<RepoPath>,
|
||||||
|
_env: HashMap<String, String>,
|
||||||
|
_cx: AsyncApp,
|
||||||
|
) -> BoxFuture<Result<()>> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn unstage_paths(
|
||||||
|
&self,
|
||||||
|
_paths: Vec<RepoPath>,
|
||||||
|
_env: HashMap<String, String>,
|
||||||
|
_cx: AsyncApp,
|
||||||
|
) -> BoxFuture<Result<()>> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn commit(
|
||||||
|
&self,
|
||||||
|
_message: SharedString,
|
||||||
|
_name_and_email: Option<(SharedString, SharedString)>,
|
||||||
|
_env: HashMap<String, String>,
|
||||||
|
_: AsyncApp,
|
||||||
|
) -> BoxFuture<Result<()>> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn push(
|
||||||
|
&self,
|
||||||
|
_branch: String,
|
||||||
|
_remote: String,
|
||||||
|
_options: Option<PushOptions>,
|
||||||
|
_ask_pass: AskPassSession,
|
||||||
|
_env: HashMap<String, String>,
|
||||||
|
_cx: AsyncApp,
|
||||||
|
) -> BoxFuture<Result<RemoteCommandOutput>> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pull(
|
||||||
|
&self,
|
||||||
|
_branch: String,
|
||||||
|
_remote: String,
|
||||||
|
_ask_pass: AskPassSession,
|
||||||
|
_env: HashMap<String, String>,
|
||||||
|
_cx: AsyncApp,
|
||||||
|
) -> BoxFuture<Result<RemoteCommandOutput>> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fetch(
|
||||||
|
&self,
|
||||||
|
_ask_pass: AskPassSession,
|
||||||
|
_env: HashMap<String, String>,
|
||||||
|
_cx: AsyncApp,
|
||||||
|
) -> BoxFuture<Result<RemoteCommandOutput>> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_remotes(
|
||||||
|
&self,
|
||||||
|
_branch: Option<String>,
|
||||||
|
_cx: AsyncApp,
|
||||||
|
) -> BoxFuture<Result<Vec<Remote>>> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check_for_pushed_commit(&self, _cx: AsyncApp) -> BoxFuture<Result<Vec<SharedString>>> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn diff(&self, _diff: DiffType, _cx: AsyncApp) -> BoxFuture<Result<String>> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,20 +5,25 @@ mod remote;
|
||||||
pub mod repository;
|
pub mod repository;
|
||||||
pub mod status;
|
pub mod status;
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
|
mod fake_repository;
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
|
pub use fake_repository::*;
|
||||||
|
|
||||||
|
pub use crate::hosting_provider::*;
|
||||||
|
pub use crate::remote::*;
|
||||||
use anyhow::{anyhow, Context as _, Result};
|
use anyhow::{anyhow, Context as _, Result};
|
||||||
|
pub use git2 as libgit;
|
||||||
use gpui::action_with_deprecated_aliases;
|
use gpui::action_with_deprecated_aliases;
|
||||||
use gpui::actions;
|
use gpui::actions;
|
||||||
|
pub use repository::WORK_DIRECTORY_REPO_PATH;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
pub use crate::hosting_provider::*;
|
|
||||||
pub use crate::remote::*;
|
|
||||||
pub use git2 as libgit;
|
|
||||||
pub use repository::WORK_DIRECTORY_REPO_PATH;
|
|
||||||
|
|
||||||
pub static DOT_GIT: LazyLock<&'static OsStr> = LazyLock::new(|| OsStr::new(".git"));
|
pub static DOT_GIT: LazyLock<&'static OsStr> = LazyLock::new(|| OsStr::new(".git"));
|
||||||
pub static GITIGNORE: LazyLock<&'static OsStr> = LazyLock::new(|| OsStr::new(".gitignore"));
|
pub static GITIGNORE: LazyLock<&'static OsStr> = LazyLock::new(|| OsStr::new(".gitignore"));
|
||||||
pub static FSMONITOR_DAEMON: LazyLock<&'static OsStr> =
|
pub static FSMONITOR_DAEMON: LazyLock<&'static OsStr> =
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use crate::status::FileStatus;
|
use crate::status::GitStatus;
|
||||||
use crate::SHORT_SHA_LENGTH;
|
use crate::SHORT_SHA_LENGTH;
|
||||||
use crate::{blame::Blame, status::GitStatus};
|
use anyhow::{anyhow, Context as _, Result};
|
||||||
use anyhow::{anyhow, Context, Result};
|
|
||||||
use askpass::{AskPassResult, AskPassSession};
|
use askpass::{AskPassResult, AskPassSession};
|
||||||
use collections::{HashMap, HashSet};
|
use collections::HashMap;
|
||||||
use futures::future::BoxFuture;
|
use futures::future::BoxFuture;
|
||||||
use futures::{select_biased, AsyncWriteExt, FutureExt as _};
|
use futures::{select_biased, AsyncWriteExt, FutureExt as _};
|
||||||
use git2::BranchType;
|
use git2::BranchType;
|
||||||
|
@ -13,11 +12,12 @@ use rope::Rope;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
|
use std::path::Component;
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
use std::{
|
use std::{
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
path::{Component, Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use sum_tree::MapSeekTarget;
|
use sum_tree::MapSeekTarget;
|
||||||
|
@ -1056,304 +1056,6 @@ async fn run_remote_command(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct FakeGitRepository {
|
|
||||||
state: Arc<Mutex<FakeGitRepositoryState>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct FakeGitRepositoryState {
|
|
||||||
pub path: PathBuf,
|
|
||||||
pub event_emitter: smol::channel::Sender<PathBuf>,
|
|
||||||
pub head_contents: HashMap<RepoPath, String>,
|
|
||||||
pub index_contents: HashMap<RepoPath, String>,
|
|
||||||
pub blames: HashMap<RepoPath, Blame>,
|
|
||||||
pub statuses: HashMap<RepoPath, FileStatus>,
|
|
||||||
pub current_branch_name: Option<String>,
|
|
||||||
pub branches: HashSet<String>,
|
|
||||||
pub simulated_index_write_error_message: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FakeGitRepository {
|
|
||||||
pub fn open(state: Arc<Mutex<FakeGitRepositoryState>>) -> Arc<dyn GitRepository> {
|
|
||||||
Arc::new(FakeGitRepository { state })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FakeGitRepositoryState {
|
|
||||||
pub fn new(path: PathBuf, event_emitter: smol::channel::Sender<PathBuf>) -> Self {
|
|
||||||
FakeGitRepositoryState {
|
|
||||||
path,
|
|
||||||
event_emitter,
|
|
||||||
head_contents: Default::default(),
|
|
||||||
index_contents: Default::default(),
|
|
||||||
blames: Default::default(),
|
|
||||||
statuses: Default::default(),
|
|
||||||
current_branch_name: Default::default(),
|
|
||||||
branches: Default::default(),
|
|
||||||
simulated_index_write_error_message: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl GitRepository for FakeGitRepository {
|
|
||||||
fn reload_index(&self) {}
|
|
||||||
|
|
||||||
fn load_index_text(&self, path: RepoPath, _: AsyncApp) -> BoxFuture<Option<String>> {
|
|
||||||
let state = self.state.lock();
|
|
||||||
let content = state.index_contents.get(path.as_ref()).cloned();
|
|
||||||
async { content }.boxed()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn load_committed_text(&self, path: RepoPath, _: AsyncApp) -> BoxFuture<Option<String>> {
|
|
||||||
let state = self.state.lock();
|
|
||||||
let content = state.head_contents.get(path.as_ref()).cloned();
|
|
||||||
async { content }.boxed()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_index_text(
|
|
||||||
&self,
|
|
||||||
path: RepoPath,
|
|
||||||
content: Option<String>,
|
|
||||||
_env: HashMap<String, String>,
|
|
||||||
_cx: AsyncApp,
|
|
||||||
) -> BoxFuture<anyhow::Result<()>> {
|
|
||||||
let mut state = self.state.lock();
|
|
||||||
if let Some(message) = state.simulated_index_write_error_message.clone() {
|
|
||||||
return async { Err(anyhow::anyhow!(message)) }.boxed();
|
|
||||||
}
|
|
||||||
if let Some(content) = content {
|
|
||||||
state.index_contents.insert(path.clone(), content);
|
|
||||||
} else {
|
|
||||||
state.index_contents.remove(&path);
|
|
||||||
}
|
|
||||||
state
|
|
||||||
.event_emitter
|
|
||||||
.try_send(state.path.clone())
|
|
||||||
.expect("Dropped repo change event");
|
|
||||||
async { Ok(()) }.boxed()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn remote_url(&self, _name: &str) -> Option<String> {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
fn head_sha(&self) -> Option<String> {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
fn merge_head_shas(&self) -> Vec<String> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn show(&self, _: String, _: AsyncApp) -> BoxFuture<Result<CommitDetails>> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn reset(&self, _: String, _: ResetMode, _: HashMap<String, String>) -> BoxFuture<Result<()>> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn checkout_files(
|
|
||||||
&self,
|
|
||||||
_: String,
|
|
||||||
_: Vec<RepoPath>,
|
|
||||||
_: HashMap<String, String>,
|
|
||||||
) -> BoxFuture<Result<()>> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn path(&self) -> PathBuf {
|
|
||||||
let state = self.state.lock();
|
|
||||||
state.path.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main_repository_path(&self) -> PathBuf {
|
|
||||||
self.path()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn status(&self, path_prefixes: &[RepoPath]) -> Result<GitStatus> {
|
|
||||||
let state = self.state.lock();
|
|
||||||
|
|
||||||
let mut entries = state
|
|
||||||
.statuses
|
|
||||||
.iter()
|
|
||||||
.filter_map(|(repo_path, status)| {
|
|
||||||
if path_prefixes
|
|
||||||
.iter()
|
|
||||||
.any(|path_prefix| repo_path.0.starts_with(path_prefix))
|
|
||||||
{
|
|
||||||
Some((repo_path.to_owned(), *status))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
entries.sort_unstable_by(|(a, _), (b, _)| a.cmp(&b));
|
|
||||||
|
|
||||||
Ok(GitStatus {
|
|
||||||
entries: entries.into(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn branches(&self) -> BoxFuture<Result<Vec<Branch>>> {
|
|
||||||
let state = self.state.lock();
|
|
||||||
let current_branch = &state.current_branch_name;
|
|
||||||
let result = Ok(state
|
|
||||||
.branches
|
|
||||||
.iter()
|
|
||||||
.map(|branch_name| Branch {
|
|
||||||
is_head: Some(branch_name) == current_branch.as_ref(),
|
|
||||||
name: branch_name.into(),
|
|
||||||
most_recent_commit: None,
|
|
||||||
upstream: None,
|
|
||||||
})
|
|
||||||
.collect());
|
|
||||||
|
|
||||||
async { result }.boxed()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn change_branch(&self, name: String, _: AsyncApp) -> BoxFuture<Result<()>> {
|
|
||||||
let mut state = self.state.lock();
|
|
||||||
state.current_branch_name = Some(name.to_owned());
|
|
||||||
state
|
|
||||||
.event_emitter
|
|
||||||
.try_send(state.path.clone())
|
|
||||||
.expect("Dropped repo change event");
|
|
||||||
async { Ok(()) }.boxed()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_branch(&self, name: String, _: AsyncApp) -> BoxFuture<Result<()>> {
|
|
||||||
let mut state = self.state.lock();
|
|
||||||
state.branches.insert(name.to_owned());
|
|
||||||
state
|
|
||||||
.event_emitter
|
|
||||||
.try_send(state.path.clone())
|
|
||||||
.expect("Dropped repo change event");
|
|
||||||
async { Ok(()) }.boxed()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn blame(
|
|
||||||
&self,
|
|
||||||
path: RepoPath,
|
|
||||||
_content: Rope,
|
|
||||||
_cx: AsyncApp,
|
|
||||||
) -> BoxFuture<Result<crate::blame::Blame>> {
|
|
||||||
let state = self.state.lock();
|
|
||||||
let result = state
|
|
||||||
.blames
|
|
||||||
.get(&path)
|
|
||||||
.with_context(|| format!("failed to get blame for {:?}", path.0))
|
|
||||||
.cloned();
|
|
||||||
async { result }.boxed()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn stage_paths(
|
|
||||||
&self,
|
|
||||||
_paths: Vec<RepoPath>,
|
|
||||||
_env: HashMap<String, String>,
|
|
||||||
_cx: AsyncApp,
|
|
||||||
) -> BoxFuture<Result<()>> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn unstage_paths(
|
|
||||||
&self,
|
|
||||||
_paths: Vec<RepoPath>,
|
|
||||||
_env: HashMap<String, String>,
|
|
||||||
_cx: AsyncApp,
|
|
||||||
) -> BoxFuture<Result<()>> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn commit(
|
|
||||||
&self,
|
|
||||||
_message: SharedString,
|
|
||||||
_name_and_email: Option<(SharedString, SharedString)>,
|
|
||||||
_env: HashMap<String, String>,
|
|
||||||
_: AsyncApp,
|
|
||||||
) -> BoxFuture<Result<()>> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn push(
|
|
||||||
&self,
|
|
||||||
_branch: String,
|
|
||||||
_remote: String,
|
|
||||||
_options: Option<PushOptions>,
|
|
||||||
_ask_pass: AskPassSession,
|
|
||||||
_env: HashMap<String, String>,
|
|
||||||
_cx: AsyncApp,
|
|
||||||
) -> BoxFuture<Result<RemoteCommandOutput>> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn pull(
|
|
||||||
&self,
|
|
||||||
_branch: String,
|
|
||||||
_remote: String,
|
|
||||||
_ask_pass: AskPassSession,
|
|
||||||
_env: HashMap<String, String>,
|
|
||||||
_cx: AsyncApp,
|
|
||||||
) -> BoxFuture<Result<RemoteCommandOutput>> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fetch(
|
|
||||||
&self,
|
|
||||||
_ask_pass: AskPassSession,
|
|
||||||
_env: HashMap<String, String>,
|
|
||||||
_cx: AsyncApp,
|
|
||||||
) -> BoxFuture<Result<RemoteCommandOutput>> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_remotes(
|
|
||||||
&self,
|
|
||||||
_branch: Option<String>,
|
|
||||||
_cx: AsyncApp,
|
|
||||||
) -> BoxFuture<Result<Vec<Remote>>> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check_for_pushed_commit(&self, _cx: AsyncApp) -> BoxFuture<Result<Vec<SharedString>>> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn diff(&self, _diff: DiffType, _cx: AsyncApp) -> BoxFuture<Result<String>> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check_path_to_repo_path_errors(relative_file_path: &Path) -> Result<()> {
|
|
||||||
match relative_file_path.components().next() {
|
|
||||||
None => anyhow::bail!("repo path should not be empty"),
|
|
||||||
Some(Component::Prefix(_)) => anyhow::bail!(
|
|
||||||
"repo path `{}` should be relative, not a windows prefix",
|
|
||||||
relative_file_path.to_string_lossy()
|
|
||||||
),
|
|
||||||
Some(Component::RootDir) => {
|
|
||||||
anyhow::bail!(
|
|
||||||
"repo path `{}` should be relative",
|
|
||||||
relative_file_path.to_string_lossy()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Some(Component::CurDir) => {
|
|
||||||
anyhow::bail!(
|
|
||||||
"repo path `{}` should not start with `.`",
|
|
||||||
relative_file_path.to_string_lossy()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Some(Component::ParentDir) => {
|
|
||||||
anyhow::bail!(
|
|
||||||
"repo path `{}` should not start with `..`",
|
|
||||||
relative_file_path.to_string_lossy()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
_ => Ok(()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub static WORK_DIRECTORY_REPO_PATH: LazyLock<RepoPath> =
|
pub static WORK_DIRECTORY_REPO_PATH: LazyLock<RepoPath> =
|
||||||
LazyLock::new(|| RepoPath(Path::new("").into()));
|
LazyLock::new(|| RepoPath(Path::new("").into()));
|
||||||
|
|
||||||
|
@ -1526,6 +1228,35 @@ fn parse_upstream_track(upstream_track: &str) -> Result<UpstreamTracking> {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn check_path_to_repo_path_errors(relative_file_path: &Path) -> Result<()> {
|
||||||
|
match relative_file_path.components().next() {
|
||||||
|
None => anyhow::bail!("repo path should not be empty"),
|
||||||
|
Some(Component::Prefix(_)) => anyhow::bail!(
|
||||||
|
"repo path `{}` should be relative, not a windows prefix",
|
||||||
|
relative_file_path.to_string_lossy()
|
||||||
|
),
|
||||||
|
Some(Component::RootDir) => {
|
||||||
|
anyhow::bail!(
|
||||||
|
"repo path `{}` should be relative",
|
||||||
|
relative_file_path.to_string_lossy()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Some(Component::CurDir) => {
|
||||||
|
anyhow::bail!(
|
||||||
|
"repo path `{}` should not start with `.`",
|
||||||
|
relative_file_path.to_string_lossy()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Some(Component::ParentDir) => {
|
||||||
|
anyhow::bail!(
|
||||||
|
"repo path `{}` should not start with `..`",
|
||||||
|
relative_file_path.to_string_lossy()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
_ => Ok(()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_branches_parsing() {
|
fn test_branches_parsing() {
|
||||||
// suppress "help: octal escapes are not supported, `\0` is always null"
|
// suppress "help: octal escapes are not supported, `\0` is always null"
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -665,6 +665,7 @@ impl Hover {
|
||||||
enum EntitySubscription {
|
enum EntitySubscription {
|
||||||
Project(PendingEntitySubscription<Project>),
|
Project(PendingEntitySubscription<Project>),
|
||||||
BufferStore(PendingEntitySubscription<BufferStore>),
|
BufferStore(PendingEntitySubscription<BufferStore>),
|
||||||
|
GitStore(PendingEntitySubscription<GitStore>),
|
||||||
WorktreeStore(PendingEntitySubscription<WorktreeStore>),
|
WorktreeStore(PendingEntitySubscription<WorktreeStore>),
|
||||||
LspStore(PendingEntitySubscription<LspStore>),
|
LspStore(PendingEntitySubscription<LspStore>),
|
||||||
SettingsObserver(PendingEntitySubscription<SettingsObserver>),
|
SettingsObserver(PendingEntitySubscription<SettingsObserver>),
|
||||||
|
@ -863,7 +864,6 @@ impl Project {
|
||||||
buffer_store.clone(),
|
buffer_store.clone(),
|
||||||
environment.clone(),
|
environment.clone(),
|
||||||
fs.clone(),
|
fs.clone(),
|
||||||
client.clone().into(),
|
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -992,7 +992,6 @@ impl Project {
|
||||||
buffer_store.clone(),
|
buffer_store.clone(),
|
||||||
environment.clone(),
|
environment.clone(),
|
||||||
ssh_proto.clone(),
|
ssh_proto.clone(),
|
||||||
ProjectId(SSH_PROJECT_ID),
|
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -1109,6 +1108,7 @@ impl Project {
|
||||||
let subscriptions = [
|
let subscriptions = [
|
||||||
EntitySubscription::Project(client.subscribe_to_entity::<Self>(remote_id)?),
|
EntitySubscription::Project(client.subscribe_to_entity::<Self>(remote_id)?),
|
||||||
EntitySubscription::BufferStore(client.subscribe_to_entity::<BufferStore>(remote_id)?),
|
EntitySubscription::BufferStore(client.subscribe_to_entity::<BufferStore>(remote_id)?),
|
||||||
|
EntitySubscription::GitStore(client.subscribe_to_entity::<GitStore>(remote_id)?),
|
||||||
EntitySubscription::WorktreeStore(
|
EntitySubscription::WorktreeStore(
|
||||||
client.subscribe_to_entity::<WorktreeStore>(remote_id)?,
|
client.subscribe_to_entity::<WorktreeStore>(remote_id)?,
|
||||||
),
|
),
|
||||||
|
@ -1137,7 +1137,7 @@ impl Project {
|
||||||
|
|
||||||
async fn from_join_project_response(
|
async fn from_join_project_response(
|
||||||
response: TypedEnvelope<proto::JoinProjectResponse>,
|
response: TypedEnvelope<proto::JoinProjectResponse>,
|
||||||
subscriptions: [EntitySubscription; 5],
|
subscriptions: [EntitySubscription; 6],
|
||||||
client: Arc<Client>,
|
client: Arc<Client>,
|
||||||
run_tasks: bool,
|
run_tasks: bool,
|
||||||
user_store: Entity<UserStore>,
|
user_store: Entity<UserStore>,
|
||||||
|
@ -1254,7 +1254,7 @@ impl Project {
|
||||||
remote_id,
|
remote_id,
|
||||||
replica_id,
|
replica_id,
|
||||||
},
|
},
|
||||||
git_store,
|
git_store: git_store.clone(),
|
||||||
buffers_needing_diff: Default::default(),
|
buffers_needing_diff: Default::default(),
|
||||||
git_diff_debouncer: DebouncedDelay::new(),
|
git_diff_debouncer: DebouncedDelay::new(),
|
||||||
terminals: Terminals {
|
terminals: Terminals {
|
||||||
|
@ -1284,6 +1284,9 @@ impl Project {
|
||||||
EntitySubscription::WorktreeStore(subscription) => {
|
EntitySubscription::WorktreeStore(subscription) => {
|
||||||
subscription.set_entity(&worktree_store, &mut cx)
|
subscription.set_entity(&worktree_store, &mut cx)
|
||||||
}
|
}
|
||||||
|
EntitySubscription::GitStore(subscription) => {
|
||||||
|
subscription.set_entity(&git_store, &mut cx)
|
||||||
|
}
|
||||||
EntitySubscription::SettingsObserver(subscription) => {
|
EntitySubscription::SettingsObserver(subscription) => {
|
||||||
subscription.set_entity(&settings_observer, &mut cx)
|
subscription.set_entity(&settings_observer, &mut cx)
|
||||||
}
|
}
|
||||||
|
@ -1874,6 +1877,9 @@ impl Project {
|
||||||
self.settings_observer.update(cx, |settings_observer, cx| {
|
self.settings_observer.update(cx, |settings_observer, cx| {
|
||||||
settings_observer.shared(project_id, self.client.clone().into(), cx)
|
settings_observer.shared(project_id, self.client.clone().into(), cx)
|
||||||
});
|
});
|
||||||
|
self.git_store.update(cx, |git_store, cx| {
|
||||||
|
git_store.shared(project_id, self.client.clone().into(), cx)
|
||||||
|
});
|
||||||
|
|
||||||
self.client_state = ProjectClientState::Shared {
|
self.client_state = ProjectClientState::Shared {
|
||||||
remote_id: project_id,
|
remote_id: project_id,
|
||||||
|
@ -1955,6 +1961,9 @@ impl Project {
|
||||||
self.settings_observer.update(cx, |settings_observer, cx| {
|
self.settings_observer.update(cx, |settings_observer, cx| {
|
||||||
settings_observer.unshared(cx);
|
settings_observer.unshared(cx);
|
||||||
});
|
});
|
||||||
|
self.git_store.update(cx, |git_store, cx| {
|
||||||
|
git_store.unshared(cx);
|
||||||
|
});
|
||||||
|
|
||||||
self.client
|
self.client
|
||||||
.send(proto::UnshareProject {
|
.send(proto::UnshareProject {
|
||||||
|
@ -2180,10 +2189,8 @@ impl Project {
|
||||||
if self.is_disconnected(cx) {
|
if self.is_disconnected(cx) {
|
||||||
return Task::ready(Err(anyhow!(ErrorCode::Disconnected)));
|
return Task::ready(Err(anyhow!(ErrorCode::Disconnected)));
|
||||||
}
|
}
|
||||||
|
self.git_store
|
||||||
self.buffer_store.update(cx, |buffer_store, cx| {
|
.update(cx, |git_store, cx| git_store.open_unstaged_diff(buffer, cx))
|
||||||
buffer_store.open_unstaged_diff(buffer, cx)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn open_uncommitted_diff(
|
pub fn open_uncommitted_diff(
|
||||||
|
@ -2194,9 +2201,8 @@ impl Project {
|
||||||
if self.is_disconnected(cx) {
|
if self.is_disconnected(cx) {
|
||||||
return Task::ready(Err(anyhow!(ErrorCode::Disconnected)));
|
return Task::ready(Err(anyhow!(ErrorCode::Disconnected)));
|
||||||
}
|
}
|
||||||
|
self.git_store.update(cx, |git_store, cx| {
|
||||||
self.buffer_store.update(cx, |buffer_store, cx| {
|
git_store.open_uncommitted_diff(buffer, cx)
|
||||||
buffer_store.open_uncommitted_diff(buffer, cx)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2755,8 +2761,8 @@ impl Project {
|
||||||
if buffers.is_empty() {
|
if buffers.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(this.buffer_store.update(cx, |buffer_store, cx| {
|
Some(this.git_store.update(cx, |git_store, cx| {
|
||||||
buffer_store.recalculate_buffer_diffs(buffers, cx)
|
git_store.recalculate_buffer_diffs(buffers, cx)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -4008,6 +4014,9 @@ impl Project {
|
||||||
buffer.update(cx, |buffer, cx| buffer.remove_peer(replica_id, cx));
|
buffer.update(cx, |buffer, cx| buffer.remove_peer(replica_id, cx));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.git_store.update(cx, |git_store, _| {
|
||||||
|
git_store.forget_shared_diffs_for(&peer_id);
|
||||||
|
});
|
||||||
|
|
||||||
cx.emit(Event::CollaboratorLeft(peer_id));
|
cx.emit(Event::CollaboratorLeft(peer_id));
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -6414,8 +6414,6 @@ async fn test_staging_lots_of_hunks_fast(cx: &mut gpui::TestAppContext) {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let range = Anchor::MIN..snapshot.anchor_after(snapshot.max_point());
|
|
||||||
|
|
||||||
let mut expected_hunks: Vec<(Range<u32>, String, String, DiffHunkStatus)> = (0..500)
|
let mut expected_hunks: Vec<(Range<u32>, String, String, DiffHunkStatus)> = (0..500)
|
||||||
.step_by(5)
|
.step_by(5)
|
||||||
.map(|i| {
|
.map(|i| {
|
||||||
|
@ -6444,9 +6442,7 @@ async fn test_staging_lots_of_hunks_fast(cx: &mut gpui::TestAppContext) {
|
||||||
|
|
||||||
// Stage every hunk with a different call
|
// Stage every hunk with a different call
|
||||||
uncommitted_diff.update(cx, |diff, cx| {
|
uncommitted_diff.update(cx, |diff, cx| {
|
||||||
let hunks = diff
|
let hunks = diff.hunks(&snapshot, cx).collect::<Vec<_>>();
|
||||||
.hunks_intersecting_range(range.clone(), &snapshot, cx)
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
for hunk in hunks {
|
for hunk in hunks {
|
||||||
diff.stage_or_unstage_hunks(true, &[hunk], &snapshot, true, cx);
|
diff.stage_or_unstage_hunks(true, &[hunk], &snapshot, true, cx);
|
||||||
}
|
}
|
||||||
|
@ -6480,9 +6476,7 @@ async fn test_staging_lots_of_hunks_fast(cx: &mut gpui::TestAppContext) {
|
||||||
|
|
||||||
// Unstage every hunk with a different call
|
// Unstage every hunk with a different call
|
||||||
uncommitted_diff.update(cx, |diff, cx| {
|
uncommitted_diff.update(cx, |diff, cx| {
|
||||||
let hunks = diff
|
let hunks = diff.hunks(&snapshot, cx).collect::<Vec<_>>();
|
||||||
.hunks_intersecting_range(range, &snapshot, cx)
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
for hunk in hunks {
|
for hunk in hunks {
|
||||||
diff.stage_or_unstage_hunks(false, &[hunk], &snapshot, true, cx);
|
diff.stage_or_unstage_hunks(false, &[hunk], &snapshot, true, cx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,14 +89,15 @@ impl HeadlessProject {
|
||||||
|
|
||||||
let environment = project::ProjectEnvironment::new(&worktree_store, None, cx);
|
let environment = project::ProjectEnvironment::new(&worktree_store, None, cx);
|
||||||
let git_store = cx.new(|cx| {
|
let git_store = cx.new(|cx| {
|
||||||
GitStore::local(
|
let mut store = GitStore::local(
|
||||||
&worktree_store,
|
&worktree_store,
|
||||||
buffer_store.clone(),
|
buffer_store.clone(),
|
||||||
environment.clone(),
|
environment.clone(),
|
||||||
fs.clone(),
|
fs.clone(),
|
||||||
session.clone().into(),
|
|
||||||
cx,
|
cx,
|
||||||
)
|
);
|
||||||
|
store.shared(SSH_PROJECT_ID, session.clone().into(), cx);
|
||||||
|
store
|
||||||
});
|
});
|
||||||
let prettier_store = cx.new(|cx| {
|
let prettier_store = cx.new(|cx| {
|
||||||
PrettierStore::new(
|
PrettierStore::new(
|
||||||
|
|
|
@ -94,6 +94,7 @@ impl BufferId {
|
||||||
self.into()
|
self.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<BufferId> for u64 {
|
impl From<BufferId> for u64 {
|
||||||
fn from(id: BufferId) -> Self {
|
fn from(id: BufferId) -> Self {
|
||||||
id.0.get()
|
id.0.get()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue