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::path_log::PathLogEntryDto; #[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)] pub struct PathLogQuery { pub commit_hash: String, pub target_dir: String, } #[utoipa::path( get, path = "/repos/{space_name}/{repo_name}/path-log", tag = "logs", description = "返回目录中每个条目的最近一次提交摘要。", params( crate::handler::RepoPath, PathLogQuery, ), responses( (status = 200, description = "path log entries", body = AppResponseData>) ) )] pub async fn path_log( State(service): State, OptionalUser(viewer): OptionalUser, Path(path): Path, Query(q): Query, ) -> Result>, ApiError> { let (ctx, _) = handler::resolve_reader( &service, viewer, path.space_name.clone(), path.repo_name.clone(), ) .await?; let entries = service .path_log(&ctx, q.commit_hash, std::path::PathBuf::from(q.target_dir)) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(entries)) }