use ::session::AuthedUser; use api::http::{Json, Path, State}; use api::rest::AppResponseData; use crate::errors::{ApiError, GitApiError}; use crate::handler; use crate::service::GitService; use crate::service::branches::{BranchDto, CreateBranchCmd}; #[utoipa::path( post, path = "/repos/{space_name}/{repo_name}/branches", tag = "branches", description = "从指定起点创建新分支引用并更新分支元数据。", params(crate::handler::RepoPath), request_body = CreateBranchCmd, responses( (status = 200, description = "create branch", body = AppResponseData) ) )] pub async fn create_branch( State(service): State, AuthedUser(uid): AuthedUser, Path(path): Path, Json(cmd): Json, ) -> Result, ApiError> { let (ctx, _) = handler::require_writer( &service, uid, path.space_name.clone(), path.repo_name.clone(), ) .await?; let out = service .create_branch(&ctx, cmd) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(out)) }