use export::http::{Path, State}; use export::rest::{AppResponseData, NoData}; use token::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) ) )] pub async fn refs_delete( State(service): State, session: Session, Path(path): Path, ) -> Result, 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)) }