Skip to content
Clone
39d7e6b
32 lines 918 B Rust
use axum::Json;
use axum::extract::State;
use export::rest::AppResponseData;
use session_layer::Session;
use crate::errors::{ApiError, GitApiError};
use crate::handler::ensure_caller;
use crate::service::GitService;
use crate::service::patches::ParsedPatchDto;
#[utoipa::path(
post,
path = "/repos/utils/patch/parse",
tag = "patches",
description = "解析补丁文本并统计涉及文件与增删行数。",
request_body = String,
responses(
(status = 200, description = "parse patch", body = AppResponseData<ParsedPatchDto>)
)
)]
pub async fn patch_parse(
State(service): State<GitService>,
session: Session,
Json(content): Json<String>,
) -> Result<AppResponseData<ParsedPatchDto>, ApiError> {
ensure_caller(&session)?;
let out = service
.patch_parse(content)
.await
.map_err(GitApiError::from)?;
Ok(AppResponseData::ok(out))
}