use crate::rpcgit::commit::types::CommitInfo; use ::session::Session; 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 CommitPath { pub space_name: String, pub repo_name: String, pub revision: String, } #[utoipa::path( get, path = "/repos/{space_name}/{repo_name}/commits/{revision}", tag = "commits", description = "读取任意修订表达式对应的单个提交详情。", params(CommitPath), responses( (status = 200, description = "get commit") ) )] pub async fn get_commit( 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 .get_commit(&ctx, path.revision) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(out)) }