use crate::rpcgit::refs::types::RefInfo; use ::session::OptionalUser; use api::http::{Path, State}; use api::rest::AppResponseData; use crate::errors::{ApiError, GitApiError}; use crate::handler; use crate::service::GitService; #[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)] pub struct RefPath { pub space_name: String, pub repo_name: String, pub name: String, } #[utoipa::path( get, path = "/repos/{space_name}/{repo_name}/refs/{name}", tag = "refs", description = "按引用名称读取单个 Git 引用。", params(RefPath), responses( (status = 200, description = "get ref") ) )] pub async fn refs_get( State(service): State, OptionalUser(viewer): OptionalUser, Path(path): Path, ) -> Result, ApiError> { let (ctx, _) = handler::resolve_reader( &service, viewer, path.space_name.clone(), path.repo_name.clone(), ) .await?; let out = service .refs_get(&ctx, path.name) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(out)) }