use ::session::Session; use export::http::{Path, Query, State}; use export::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, session: Session, Path(path): Path, Query(q): Query, ) -> Result>, ApiError> { let _ = handler::resolve_reader( &service, &session, path.space_name.clone(), path.repo_name.clone(), ) .await?; let entries = service .path_log( path.space_name, path.repo_name, q.commit_hash, std::path::PathBuf::from(q.target_dir), ) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(entries)) }