Skip to content
Clone
5f84089
33 lines 1.0 KB Rust
use ::session::Session;
use export::http::{Json, Path, State};
use export::rest::AppResponseData;
use crate::errors::{ApiError, GitApiError};
use crate::handler::{RepoPath, ensure_caller};
use crate::service::GitService;
use crate::service::repos::{RepoDto, UpdateRepoCmd};
#[utoipa::path(
patch,
path = "/repos/{space_name}/{repo_name}",
tag = "repos",
description = "更新仓库描述、主页、可见性、LFS 和默认分支;仅空间所有者可操作。",
params(RepoPath),
request_body = UpdateRepoCmd,
responses(
(status = 200, description = "update repo", body = AppResponseData<RepoDto>)
)
)]
pub async fn update_repo(
State(service): State<GitService>,
session: Session,
Path(path): Path<RepoPath>,
Json(cmd): Json<UpdateRepoCmd>,
) -> Result<AppResponseData<RepoDto>, ApiError> {
let caller = ensure_caller(&session)?;
let out = service
.update_repo(path.space_name, path.repo_name, caller, cmd)
.await
.map_err(GitApiError::from)?;
Ok(AppResponseData::ok(out))
}