4dc6d37
ZhenYi
fix(sync): pool multiplexed consumer connections, real queue topics, ssh carries sync settings; regenerate openapi.json
4dc6d37
use axum::extract::{Path, Query, State};
use export::rest::{AppResponseData, NoData};
use session::Session;
use crate::errors::{ApiError, GitApiError};
use crate::handler::require_writer;
use crate::service::GitService;
#[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)]
pub struct BranchPath {
pub space_name: String,
pub repo_name: String,
pub name: String,
}
#[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)]
pub struct DeleteBranchQuery {
#[serde(default)]
pub force: Option<bool>,
}
#[utoipa::path(
delete,
path = "/repos/{space_name}/{repo_name}/branches/{name}",
tag = "branches",
params(BranchPath, DeleteBranchQuery),
responses(
(status = 200, description = "delete branch", body = AppResponseData<NoData>)
)
)]
pub async fn delete_branch(
State(service): State<GitService>,
session: Session,
Path(path): Path<BranchPath>,
Query(query): Query<DeleteBranchQuery>,
) -> Result<AppResponseData<NoData>, ApiError> {
let _ = require_writer(&service, &session, path.space_name.clone(), path.repo_name.clone()).await?;
service
.delete_branch(
path.space_name,
path.repo_name,
path.name,
query.force.unwrap_or(false),
)
.await
.map_err(GitApiError::from)?;
Ok(AppResponseData::ok(NoData))
}