summaryrefslogtreecommitdiff
path: root/internal/deployment
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-03-16 04:24:19 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-03-16 04:24:19 +0000
commitd75a231d8865d9b14fbe3d608c9aa1bffb7ed386 (patch)
tree1875147811c1cbf5b85260dc5fc5be8986902f68 /internal/deployment
parent16ff7ca46bfb4af44af488fa95bd3f8e981f4db2 (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/deployment')
-rw-r--r--internal/deployment/deployment.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/internal/deployment/deployment.go b/internal/deployment/deployment.go
new file mode 100644
index 0000000..0ba436d
--- /dev/null
+++ b/internal/deployment/deployment.go
@@ -0,0 +1,43 @@
+package deployment
+
+import (
+ "os/exec"
+
+ "github.com/thepeterstone/claudomator/internal/task"
+ "github.com/thepeterstone/claudomator/internal/version"
+)
+
+// Status describes whether the currently-deployed server includes a set of fix commits.
+type Status struct {
+ DeployedCommit string `json:"deployed_commit"`
+ FixCommits []task.GitCommit `json:"fix_commits"`
+ IncludesFix bool `json:"includes_fix"`
+}
+
+// Check returns the deployment status for a set of fix commits given the project directory.
+// It uses `git merge-base --is-ancestor` to check whether each fix commit is an ancestor
+// of the deployed server's commit. Returns a non-nil Status in all cases; IncludesFix is
+// false when the check cannot be performed (missing git, "dev" version, no commits, etc.).
+func Check(fixCommits []task.GitCommit, projectDir string) *Status {
+ deployedCommit := version.Version()
+ status := &Status{
+ DeployedCommit: deployedCommit,
+ FixCommits: fixCommits,
+ }
+ if deployedCommit == "dev" || projectDir == "" || len(fixCommits) == 0 {
+ return status
+ }
+
+ // All fix commits must be ancestors of (or equal to) the deployed commit.
+ for _, commit := range fixCommits {
+ if commit.Hash == "" {
+ continue
+ }
+ cmd := exec.Command("git", "-C", projectDir, "merge-base", "--is-ancestor", commit.Hash, deployedCommit)
+ if err := cmd.Run(); err != nil {
+ return status
+ }
+ }
+ status.IncludesFix = true
+ return status
+}