git: Add handler to get default branch on remote (#36157)

Closes #36150 

Release Notes:

- Fixed `git: branch` action not worked with ssh workflow
This commit is contained in:
Alvaro Parker 2025-08-14 02:10:38 -04:00 committed by GitHub
parent 5bbdd1a262
commit 0291db0d78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -414,6 +414,7 @@ impl GitStore {
pub fn init(client: &AnyProtoClient) {
client.add_entity_request_handler(Self::handle_get_remotes);
client.add_entity_request_handler(Self::handle_get_branches);
client.add_entity_request_handler(Self::handle_get_default_branch);
client.add_entity_request_handler(Self::handle_change_branch);
client.add_entity_request_handler(Self::handle_create_branch);
client.add_entity_request_handler(Self::handle_git_init);
@ -1894,6 +1895,23 @@ impl GitStore {
.collect::<Vec<_>>(),
})
}
async fn handle_get_default_branch(
this: Entity<Self>,
envelope: TypedEnvelope<proto::GetDefaultBranch>,
mut cx: AsyncApp,
) -> Result<proto::GetDefaultBranchResponse> {
let repository_id = RepositoryId::from_proto(envelope.payload.repository_id);
let repository_handle = Self::repository_for_request(&this, repository_id, &mut cx)?;
let branch = repository_handle
.update(&mut cx, |repository_handle, _| {
repository_handle.default_branch()
})?
.await??
.map(Into::into);
Ok(proto::GetDefaultBranchResponse { branch })
}
async fn handle_create_branch(
this: Entity<Self>,
envelope: TypedEnvelope<proto::GitCreateBranch>,