use ::session::Session; use export::http::{Path, State}; use export::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}/resolve", tag = "refs", description = "将引用名或修订表达式解析为完整对象 ID。", params(RefPath), responses( (status = 200, description = "resolve ref", body = AppResponseData) ) )] pub async fn refs_resolve( State(service): State, session: Session, Path(path): Path, ) -> Result, ApiError> { let (ctx, _) = handler::resolve_reader( &service, &session, path.space_name.clone(), path.repo_name.clone(), ) .await?; let out = service .refs_resolve(&ctx, path.name) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(out)) }