use axum::Json; use axum::extract::{Path, State}; use export::rest::AppResponseData; use session::Session; use crate::errors::{ApiError, GitApiError}; use crate::handler::require_writer; use crate::service::GitService; use crate::service::hooks::ScriptOutputDto; #[derive(Debug, Clone, serde::Deserialize)] pub struct HookScriptPath { pub space_name: String, pub repo_name: String, pub script: String, } #[derive(Debug, Clone, serde::Deserialize)] pub struct HookExecBody { #[serde(default)] pub args: Vec, } pub async fn execute_script( State(service): State, session: Session, Path(path): Path, Json(body): Json, ) -> Result, ApiError> { require_writer(&service, &session, path.space_name.clone(), path.repo_name.clone()).await?; let out = service .hook_execute_script(path.space_name, path.repo_name, path.script, body.args) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(out)) }