2ae9196
ZhenYi
feat(lib/git): add HTTP handler tree with routes and errors across analysis, archives, blobs, branches, commits, conflicts, content, diffs, hooks, lfs, logs, maintenance, packs, patches, pipelines, refs, remotes, repos, signatures, submodules, tags, trees
2ae9196
use axum::extract::{Path, State};
use export::rest::{AppResponseData, NoData};
use session::Session;
use crate::errors::{ApiError, GitApiError};
use crate::handler::require_writer;
use crate::service::GitService;
#[derive(Debug, Clone, serde::Deserialize)]
pub struct BranchPath {
pub space_name: String,
pub repo_name: String,
pub name: String,
}
pub async fn set_default_branch(
State(service): State<GitService>,
session: Session,
Path(path): Path<BranchPath>,
) -> Result<AppResponseData<NoData>, ApiError> {
let _ = require_writer(&service, &session, path.space_name.clone(), path.repo_name.clone()).await?;
service
.set_default_branch(path.space_name, path.repo_name, path.name)
.await
.map_err(GitApiError::from)?;
Ok(AppResponseData::ok(NoData))
}