2ae9196
ZhenYi
feat(lib/git): add HTTP handler tree with routes and errors across analysis, archives, blobs, branches, commits, conflicts, content, diffs, hooks, lfs, logs, maintenance, packs, patches, pipelines, refs, remotes, repos, signatures, submodules, tags, trees
2ae9196
use axum::extract::{Path, Query, State};
use export::rest::AppResponseData;
use session::Session;
use crate::errors::{ApiError, GitApiError};
use crate::handler::resolve_reader;
use crate::service::GitService;
use crate::service::path_log::PathLogEntryDto;
#[derive(Debug, Clone, serde::Deserialize)]
pub struct PathLogQuery {
pub commit_hash: String,
pub target_dir: String,
}
pub async fn path_log(
State(service): State<GitService>,
session: Session,
Path(path): Path<crate::handler::RepoPath>,
Query(q): Query<PathLogQuery>,
) -> Result<AppResponseData<Vec<PathLogEntryDto>>, ApiError> {
let _ = 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))
}