rdev/internal/handlers/sdlc_branches.go
jordan f22b220c6d feat: add SDLC branch management, merge, archive, and orchestrator APIs
Add branch lifecycle commands (branch, merge, archive) to the SDLC CLI.
Introduce orchestrator handler and service for multi-step SDLC workflows.
Expand skeleton template with 15 Claude commands covering the full feature
lifecycle. Extend classifier rules, error types, and executor port for
branch operations. Split rules.go and classifier_test.go to stay within
500-line limit.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 12:30:03 -07:00

63 lines
1.6 KiB
Go

package handlers
import (
"context"
"net/http"
"github.com/go-chi/chi/v5"
"github.com/orchard9/rdev/pkg/api"
)
// CreateBranch creates a feature branch.
// POST /projects/{id}/sdlc/features/{slug}/branches
func (h *SDLCHandler) CreateBranch(w http.ResponseWriter, r *http.Request) {
projectID := chi.URLParam(r, "id")
slug := chi.URLParam(r, "slug")
ctx, cancel := context.WithTimeout(r.Context(), TimeoutHeavyWrite)
defer cancel()
manifest, err := h.sdlcService.CreateBranch(ctx, projectID, slug)
if err != nil {
writeSDLCError(w, r, err)
return
}
api.WriteCreated(w, r, manifest)
}
// GetBranchStatus returns the branch manifest for a feature.
// GET /projects/{id}/sdlc/features/{slug}/branches
func (h *SDLCHandler) GetBranchStatus(w http.ResponseWriter, r *http.Request) {
projectID := chi.URLParam(r, "id")
slug := chi.URLParam(r, "slug")
ctx, cancel := context.WithTimeout(r.Context(), TimeoutStandard)
defer cancel()
manifest, err := h.sdlcService.GetBranchStatus(ctx, projectID, slug)
if err != nil {
writeSDLCError(w, r, err)
return
}
api.WriteSuccess(w, r, manifest)
}
// SyncBranch syncs a feature branch with its base branch.
// POST /projects/{id}/sdlc/features/{slug}/branches/sync
func (h *SDLCHandler) SyncBranch(w http.ResponseWriter, r *http.Request) {
projectID := chi.URLParam(r, "id")
slug := chi.URLParam(r, "slug")
ctx, cancel := context.WithTimeout(r.Context(), TimeoutHeavyWrite)
defer cancel()
if err := h.sdlcService.SyncBranch(ctx, projectID, slug); err != nil {
writeSDLCError(w, r, err)
return
}
api.WriteSuccess(w, r, map[string]string{"status": "synced"})
}