feat(service): expand service layer with new domain operations
- Add IM service modules: audit, channel roles, custom emojis, forum tags, integrations, invitations, repo links, slash commands, stages, voice, webhooks - Add PR service modules: review requests, templates - Add repo service modules: contributors, release assets, git extras (archive, branch rename, commit extras, diff/merge, tag, tree) - Add user service: social (follow/block) - Add internal auth service - Update existing service modules with expanded functionality - Remove deleted IM modules: articles, delivery trace, drafts, follows, messages, polls, presence, reactions, threads
This commit is contained in:
@@ -120,4 +120,29 @@ impl RepoService {
|
||||
.map_err(|e| AppError::InternalServerError(e.to_string()))?;
|
||||
Ok(resp.into_inner())
|
||||
}
|
||||
|
||||
pub async fn git_set_default_branch(
|
||||
&self,
|
||||
ctx: &Session,
|
||||
wk_name: &str,
|
||||
repo_name: &str,
|
||||
branch_name: &str,
|
||||
) -> Result<(), AppError> {
|
||||
let user_uid = ctx.user().ok_or(AppError::Unauthorized)?;
|
||||
let repo = self.resolve_repo(wk_name, repo_name).await?;
|
||||
self.ensure_repo_role_at_least(user_uid, &repo, crate::models::common::Role::Admin)
|
||||
.await?;
|
||||
let ws = self.resolve_workspace(wk_name).await?;
|
||||
let header = self.repo_header(&repo, &ws);
|
||||
let mut svc = self.git_client(&repo)?.repository;
|
||||
svc.set_default_branch(tonic::Request::new(
|
||||
crate::pb::repo::SetDefaultBranchRequest {
|
||||
repository: Some(header),
|
||||
name: branch_name.to_string(),
|
||||
},
|
||||
))
|
||||
.await
|
||||
.map_err(|e| AppError::InternalServerError(e.to_string()))?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user