Skip to content
Clone
ffe7f41
33 lines 1.1 KB Rust
use axum::extract::{Path, State};
use export::data::AppResponseData;
use jwt::extractor::AuthUser;
use uuid::Uuid;
use crate::error::RepoResult;
use crate::features::RepoService;
use crate::features::git_ref::CommitView;
#[utoipa::path(
get,
path = "/repos/{space_name}/{repo_id}/git/commits/{sha}",
tag = "repo",
params(
("space_name" = String, Path),
("repo_id" = Uuid, Path),
("sha" = String, Path),
),
responses((status = 200, description = "Get a commit", body = AppResponseData<CommitView>)),
security(("bearer_auth" = []))
)]
pub(crate) async fn handler(
State(svc): State<RepoService>,
AuthUser { claims }: AuthUser,
Path((space_name, repo_id, sha)): Path<(String, Uuid, String)>,
) -> RepoResult<AppResponseData<CommitView>> {
let space_id = space::features::lookup::lookup_space_by_name(&svc, &space_name).await?;
space::features::authz::require_active_member(&svc, claims.sub, space_id).await?;
let _channel_id = crate::features::lookup::channel_for_repo(&svc, repo_id).await?;
let view = svc.get_commit(claims.sub, repo_id, &sha).await?;
Ok(AppResponseData::ok(view))
}