Skip to content
Clone
35ef7e8
37 lines 1.1 KB Rust
use ::session::Session;
use export::http::{Path, State};
use export::rest::AppResponseData;
use crate::errors::{ApiError, GitApiError};
use crate::handler::{RepoPath, require_writer};
use crate::service::GitService;
use crate::service::archives::ArchiveResultDto;
#[utoipa::path(
post,
path = "/repos/{space_name}/{repo_name}/archives/bundle",
tag = "archives",
description = "将仓库全部引用打包为 Git bundle 并上传存储。",
params(RepoPath),
responses(
(status = 200, description = "create git bundle", body = AppResponseData<ArchiveResultDto>)
)
)]
pub async fn create_bundle(
State(service): State<GitService>,
session: Session,
Path(path): Path<RepoPath>,
) -> Result<AppResponseData<ArchiveResultDto>, ApiError> {
require_writer(
&service,
&session,
path.space_name.clone(),
path.repo_name.clone(),
)
.await?;
let out = service
.archive_create_bundle(path.space_name, path.repo_name)
.await
.map_err(GitApiError::from)?;
Ok(AppResponseData::ok(out))
}