diff --git a/crates/collab/tests/integration/integration_tests.rs b/crates/collab/tests/integration/integration_tests.rs index dac33f9855b303..f562758bf2886b 100644 --- a/crates/collab/tests/integration/integration_tests.rs +++ b/crates/collab/tests/integration/integration_tests.rs @@ -7315,6 +7315,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 6ec98f522ec9f6..741b9e98026457 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -3137,7 +3137,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); @@ -7809,6 +7809,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 ac7e39a83d96c8..9a22bed5a4a46c 100644 --- a/crates/proto/proto/git.proto +++ b/crates/proto/proto/git.proto @@ -507,6 +507,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 4663ffea3a0a06..e0b3ecb218227c 100644 --- a/crates/remote_server/src/remote_editing_tests.rs +++ b/crates/remote_server/src/remote_editing_tests.rs @@ -2207,6 +2207,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]