diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-16 04:24:19 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-16 04:24:19 +0000 |
| commit | d75a231d8865d9b14fbe3d608c9aa1bffb7ed386 (patch) | |
| tree | 1875147811c1cbf5b85260dc5fc5be8986902f68 /internal/api/deployment.go | |
| parent | 16ff7ca46bfb4af44af488fa95bd3f8e981f4db2 (diff) | |
feat: add deployment status endpoint for tasks
Adds GET /api/tasks/{id}/deployment-status which checks whether the
currently-deployed server binary includes the fix commits from the
task's latest execution. Uses git merge-base --is-ancestor to compare
commit hashes against the running version.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/api/deployment.go')
| -rw-r--r-- | internal/api/deployment.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/api/deployment.go b/internal/api/deployment.go new file mode 100644 index 0000000..d927545 --- /dev/null +++ b/internal/api/deployment.go @@ -0,0 +1,36 @@ +package api + +import ( + "database/sql" + "net/http" + + "github.com/thepeterstone/claudomator/internal/deployment" +) + +// handleGetDeploymentStatus returns whether the currently-deployed server +// includes the commits that were produced by this task's latest execution. +// GET /api/tasks/{id}/deployment-status +func (s *Server) handleGetDeploymentStatus(w http.ResponseWriter, r *http.Request) { + id := r.PathValue("id") + + tk, err := s.store.GetTask(id) + if err != nil { + writeJSON(w, http.StatusNotFound, map[string]string{"error": "task not found"}) + return + } + + exec, err := s.store.GetLatestExecution(tk.ID) + if err != nil { + if err == sql.ErrNoRows { + // No execution yet — return status with no fix commits. + status := deployment.Check(nil, tk.Agent.ProjectDir) + writeJSON(w, http.StatusOK, status) + return + } + writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()}) + return + } + + status := deployment.Check(exec.Commits, tk.Agent.ProjectDir) + writeJSON(w, http.StatusOK, status) +} |
