Git improvements (#24238)
- **Base diffs on uncommitted changes** - **Show added files in project diff view** - **Fix git panel optimism** Release Notes: - Git: update diffs to be relative to HEAD instead of the index; to pave the way for showing which hunks are staged --------- Co-authored-by: Cole <cole@zed.dev>
This commit is contained in:
parent
22b7042b9e
commit
0963401a8d
11 changed files with 241 additions and 231 deletions
|
@ -1285,7 +1285,7 @@ impl Editor {
|
|||
|
||||
let mut code_action_providers = Vec::new();
|
||||
if let Some(project) = project.clone() {
|
||||
get_unstaged_changes_for_buffers(
|
||||
get_uncommitted_changes_for_buffer(
|
||||
&project,
|
||||
buffer.read(cx).all_buffers(),
|
||||
buffer.clone(),
|
||||
|
@ -13657,7 +13657,7 @@ impl Editor {
|
|||
let buffer_id = buffer.read(cx).remote_id();
|
||||
if self.buffer.read(cx).change_set_for(buffer_id).is_none() {
|
||||
if let Some(project) = &self.project {
|
||||
get_unstaged_changes_for_buffers(
|
||||
get_uncommitted_changes_for_buffer(
|
||||
project,
|
||||
[buffer.clone()],
|
||||
self.buffer.clone(),
|
||||
|
@ -14413,7 +14413,7 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_unstaged_changes_for_buffers(
|
||||
fn get_uncommitted_changes_for_buffer(
|
||||
project: &Entity<Project>,
|
||||
buffers: impl IntoIterator<Item = Entity<Buffer>>,
|
||||
buffer: Entity<MultiBuffer>,
|
||||
|
@ -14422,7 +14422,7 @@ fn get_unstaged_changes_for_buffers(
|
|||
let mut tasks = Vec::new();
|
||||
project.update(cx, |project, cx| {
|
||||
for buffer in buffers {
|
||||
tasks.push(project.open_unstaged_changes(buffer.clone(), cx))
|
||||
tasks.push(project.open_uncommitted_changes(buffer.clone(), cx))
|
||||
}
|
||||
});
|
||||
cx.spawn(|mut cx| async move {
|
||||
|
|
|
@ -5619,13 +5619,13 @@ async fn test_fold_function_bodies(cx: &mut gpui::TestAppContext) {
|
|||
|
||||
let base_text = r#"
|
||||
impl A {
|
||||
// this is an unstaged comment
|
||||
// this is an uncommitted comment
|
||||
|
||||
fn b() {
|
||||
c();
|
||||
}
|
||||
|
||||
// this is another unstaged comment
|
||||
// this is another uncommitted comment
|
||||
|
||||
fn d() {
|
||||
// e
|
||||
|
@ -5668,13 +5668,13 @@ async fn test_fold_function_bodies(cx: &mut gpui::TestAppContext) {
|
|||
cx.assert_state_with_diff(
|
||||
"
|
||||
ˇimpl A {
|
||||
- // this is an unstaged comment
|
||||
- // this is an uncommitted comment
|
||||
|
||||
fn b() {
|
||||
c();
|
||||
}
|
||||
|
||||
- // this is another unstaged comment
|
||||
- // this is another uncommitted comment
|
||||
-
|
||||
fn d() {
|
||||
// e
|
||||
|
@ -5691,13 +5691,13 @@ async fn test_fold_function_bodies(cx: &mut gpui::TestAppContext) {
|
|||
|
||||
let expected_display_text = "
|
||||
impl A {
|
||||
// this is an unstaged comment
|
||||
// this is an uncommitted comment
|
||||
|
||||
fn b() {
|
||||
⋯
|
||||
}
|
||||
|
||||
// this is another unstaged comment
|
||||
// this is another uncommitted comment
|
||||
|
||||
fn d() {
|
||||
⋯
|
||||
|
|
|
@ -290,7 +290,7 @@ impl EditorTestContext {
|
|||
editor.project.as_ref().unwrap().read(cx).fs().as_fake()
|
||||
});
|
||||
let path = self.update_buffer(|buffer, _| buffer.file().unwrap().path().clone());
|
||||
fs.set_index_for_repo(
|
||||
fs.set_head_for_repo(
|
||||
&Self::root_path().join(".git"),
|
||||
&[(path.into(), diff_base.to_string())],
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue