Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix remote worktree picker hides "Create from origin/main" option (#59134)

Tyler Benfield503292376ed0
diff --git a/crates/collab/tests/integration/integration_tests.rs b/crates/collab/tests/integration/integration_tests.rs
index c4650971d2a..38cac226bad 100644
--- a/crates/collab/tests/integration/integration_tests.rs
+++ b/crates/collab/tests/integration/integration_tests.rs
@@ -7310,6 +7310,20 @@ async fn test_remote_git_branches(
});
assert_eq!(host_branch.name(), "totally-new-branch");
+
+ let default_branch_b = cx_b
+ .update(|cx| repo_b.update(cx, |repository, _cx| repository.default_branch(false)))
+ .await
+ .unwrap()
+ .unwrap();
+ assert_eq!(default_branch_b.as_deref(), Some("main"));
+
+ let default_branch_with_remote_b = cx_b
+ .update(|cx| repo_b.update(cx, |repository, _cx| repository.default_branch(true)))
+ .await
+ .unwrap()
+ .unwrap();
+ assert_eq!(default_branch_with_remote_b.as_deref(), Some("origin/main"));
}
#[gpui::test]
diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs
index 6bf3fb85005..550433c7ec8 100644
--- a/crates/project/src/git_store.rs
+++ b/crates/project/src/git_store.rs
@@ -3540,7 +3540,7 @@ impl GitStore {
let branch = repository_handle
.update(&mut cx, |repository_handle, _| {
- repository_handle.default_branch(false)
+ repository_handle.default_branch(envelope.payload.include_remote_name)
})
.await??
.map(Into::into);
@@ -8349,6 +8349,7 @@ impl Repository {
.request(proto::GetDefaultBranch {
project_id: project_id.0,
repository_id: id.to_proto(),
+ include_remote_name,
})
.await?;
diff --git a/crates/proto/proto/git.proto b/crates/proto/proto/git.proto
index 8d589f947cd..1592237cda8 100644
--- a/crates/proto/proto/git.proto
+++ b/crates/proto/proto/git.proto
@@ -512,6 +512,7 @@ message BlameBufferResponse {
message GetDefaultBranch {
uint64 project_id = 1;
uint64 repository_id = 2;
+ bool include_remote_name = 3;
}
message GetDefaultBranchResponse {
diff --git a/crates/remote_server/src/remote_editing_tests.rs b/crates/remote_server/src/remote_editing_tests.rs
index 46e2eb1eb62..53aec1f5673 100644
--- a/crates/remote_server/src/remote_editing_tests.rs
+++ b/crates/remote_server/src/remote_editing_tests.rs
@@ -2800,6 +2800,20 @@ async fn test_remote_git_branches(cx: &mut TestAppContext, server_cx: &mut TestA
});
assert_eq!(server_branch.name(), "totally-new-branch");
+
+ let default_branch = cx
+ .update(|cx| repository.update(cx, |repository, _cx| repository.default_branch(false)))
+ .await
+ .unwrap()
+ .unwrap();
+ assert_eq!(default_branch.as_deref(), Some("main"));
+
+ let default_branch_with_remote = cx
+ .update(|cx| repository.update(cx, |repository, _cx| repository.default_branch(true)))
+ .await
+ .unwrap()
+ .unwrap();
+ assert_eq!(default_branch_with_remote.as_deref(), Some("origin/main"));
}
#[gpui::test]