Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / infra / agents / agentd / src / hooks.rs
hooks.rs20 lines · 1.0 KiBRaw
| 1 | //! Post-push hook: runs after a successful Approve push, never fails it. |
| 2 | |
| 3 | use crate::agent::DriverCtx; |
| 4 | use crate::issues::AfterPush; |
| 5 | use crate::models::EVENT_STATUS; |
| 6 | |
| 7 | /// Called after a task's WIP ref is pushed to its branch on Approve: for |
| 8 | /// issue-linked tasks, comment on the GitHub issue and add the |
| 9 | /// "solved for next release" label. The caller ignores the `Result`, so a |
| 10 | /// GitHub failure never fails the approve; it is surfaced as a status event. |
| 11 | pub async fn after_push(ctx: &DriverCtx, task: &crate::models::Task) -> Result<(), String> { |
| 12 | let message = match crate::issues::after_push(ctx, task).await { |
| 13 | AfterPush::NoIssue => return Ok(()), |
| 14 | AfterPush::Posted { comment_url } => format!("commented on issue: {comment_url}"), |
| 15 | AfterPush::NoToken => "issue not updated: no AGENTD_GITHUB_TOKEN configured".to_string(), |
| 16 | AfterPush::Failed { message } => format!("issue update failed: {message}"), |
| 17 | }; |
| 18 | ctx.emit(task.id, EVENT_STATUS, serde_json::json!({ "message": message })); |
| 19 | Ok(()) |
| 20 | } |