From d75a231d8865d9b14fbe3d608c9aa1bffb7ed386 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Mon, 16 Mar 2026 04:24:19 +0000 Subject: 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 --- internal/deployment/deployment.go | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 internal/deployment/deployment.go (limited to 'internal/deployment/deployment.go') 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 +} -- cgit v1.2.3