Skip to content
Clone
c2013a0
52 lines 1.4 KB Rust
use axum::Json;
use axum::extract::{Path, 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::conflicts::MergeStatusDto;
#[derive(Debug, Clone, serde::Deserialize, utoipa::ToSchema)]
pub struct ConflictCheckThreewayBody {
pub ours: String,
pub theirs: String,
pub ancestor: String,
}
#[utoipa::path(
post,
path = "/repos/{space_name}/{repo_name}/conflicts/check-threeway",
tag = "conflicts",
params(crate::handler::RepoPath),
request_body = ConflictCheckThreewayBody,
responses(
(status = 200, description = "three-way merge conflict check", body = AppResponseData<MergeStatusDto>)
)
)]
pub async fn conflict_check_threeway(
State(service): State<GitService>,
session: Session,
Path(path): Path<crate::handler::RepoPath>,
Json(body): Json<ConflictCheckThreewayBody>,
) -> Result<AppResponseData<MergeStatusDto>, ApiError> {
let _ = resolve_reader(
&service,
&session,
path.space_name.clone(),
path.repo_name.clone(),
)
.await?;
let out = service
.conflict_check_threeway(
path.space_name,
path.repo_name,
body.ours,
body.theirs,
body.ancestor,
)
.await
.map_err(GitApiError::from)?;
Ok(AppResponseData::ok(out))
}