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 RevPath { pub space_name: String, pub repo_name: String, pub revision: String, } #[utoipa::path( get, path = "/repos/{space_name}/{repo_name}/rev/{revision}", tag = "commits", description = "将分支、标签、短 SHA 或相对修订表达式解析为对象 ID。", params(RevPath), responses( (status = 200, description = "parse revision", body = AppResponseData) ) )] pub async fn rev_parse( State(service): State, session: Session, Path(path): Path, ) -> Result, ApiError> { let _ = handler::resolve_reader( &service, &session, path.space_name.clone(), path.repo_name.clone(), ) .await?; let out = service .rev_parse(path.space_name, path.repo_name, path.revision) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(out)) }