use export::http::{Json, Path, State}; use export::rest::AppResponseData; use token::Session; 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, session: Session, Path(path): Path, Json(cmd): Json, ) -> Result, ApiError> { let _ = handler::require_writer( &service, &session, path.space_name.clone(), path.repo_name.clone(), ) .await?; let out = service .create_branch(path.space_name, path.repo_name, cmd) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(out)) }