Skip to content
Clone
b7cd2b1
43 lines 1.2 KB Rust
use export::http::{Path, State};
use export::rest::{AppResponseData, NoData};
use jwt::Session;
use crate::errors::{ApiError, GitApiError};
use crate::handler;
use crate::service::GitService;
#[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)]
pub struct RefPath {
pub space_name: String,
pub repo_name: String,
pub name: String,
}
#[utoipa::path(
delete,
path = "/repos/{space_name}/{repo_name}/refs/{name}",
tag = "refs",
description = "删除完全限定的 Git 引用;受保护分支或标签会被拒绝。",
params(RefPath),
responses(
(status = 200, description = "delete ref", body = AppResponseData<NoData>)
)
)]
pub async fn refs_delete(
State(service): State<GitService>,
session: Session,
Path(path): Path<RefPath>,
) -> Result<AppResponseData<NoData>, ApiError> {
let _ = handler::require_writer(
&service,
&session,
path.space_name.clone(),
path.repo_name.clone(),
)
.await?;
service
.refs_delete(path.space_name, path.repo_name, path.name)
.await
.map_err(GitApiError::from)?;
Ok(AppResponseData::ok(NoData))
}