Skip to content
Clone
5f84089
43 lines 1.1 KB Rust
use ::session::Session;
use export::http::{Path, State};
use export::rest::{AppResponseData, NoData};
use crate::errors::{ApiError, GitApiError};
use crate::handler;
use crate::service::GitService;
#[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)]
pub struct RemotePath {
pub space_name: String,
pub repo_name: String,
pub name: String,
}
#[utoipa::path(
delete,
path = "/repos/{space_name}/{repo_name}/remotes/{name}",
tag = "remotes",
description = "删除仓库配置的指定远程。",
params(RemotePath),
responses(
(status = 200, description = "remove remote", body = AppResponseData<NoData>)
)
)]
pub async fn remove(
State(service): State<GitService>,
session: Session,
Path(path): Path<RemotePath>,
) -> Result<AppResponseData<NoData>, ApiError> {
handler::require_writer(
&service,
&session,
path.space_name.clone(),
path.repo_name.clone(),
)
.await?;
service
.remote_remove(path.space_name, path.repo_name, path.name)
.await
.map_err(GitApiError::from)?;
Ok(AppResponseData::ok(NoData))
}