use export::http::{Path, Query, State}; use export::rest::AppResponseData; use token::Session; use crate::errors::{ApiError, GitApiError}; use crate::handler; use crate::service::GitService; use crate::service::conflicts::MergeStatusDto; #[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)] pub struct GetConflictsQuery { pub base: String, pub head: String, #[serde(default)] pub ancestor: Option, } #[utoipa::path( get, path = "/repos/{space_name}/{repo_name}/conflicts", tag = "conflicts", description = "检测两个修订合并时是否冲突,并返回可快进标记。", params(crate::handler::RepoPath, GetConflictsQuery), responses( (status = 200, description = "merge conflict status", body = AppResponseData) ) )] pub async fn get_conflicts( 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 out = match q.ancestor { Some(ancestor) => { service .conflict_check_threeway(path.space_name, path.repo_name, q.base, q.head, ancestor) .await } None => { service .conflict_check(path.space_name, path.repo_name, q.base, q.head) .await } } .map_err(GitApiError::from)?; Ok(AppResponseData::ok(out)) }