use ::session::OptionalUser; use api::http::{Path, Query, State}; use api::rest::AppResponseData; use crate::errors::{ApiError, GitApiError}; use crate::handler; use crate::service::GitService; use crate::service::refs::BranchInfoDto; #[utoipa::path( get, path = "/repos/{space_name}/{repo_name}/refs/branches", tag = "refs", description = "返回分支引用摘要及保护标记,供内部 Git 流程分页使用。", params(crate::handler::RepoPath, api::pagination::PageQuery), responses( (status = 200, description = "list branch refs", body = AppResponseData>) ) )] pub async fn refs_branches( State(service): State, OptionalUser(viewer): OptionalUser, Path(path): Path, Query(query): Query, ) -> Result>, ApiError> { let (ctx, _) = handler::resolve_reader( &service, viewer, path.space_name.clone(), path.repo_name.clone(), ) .await?; let (limit, offset) = query.bounds()?; let out = service .refs_branches(&ctx, limit, offset) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(out)) }