Change summary
crates/project/src/git_store.rs | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
Detailed changes
@@ -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>,