rdev/internal/handlers/sdlc_merge.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

62 lines
1.6 KiB
Go

package handlers
import (
"context"
"net/http"
"github.com/go-chi/chi/v5"
"github.com/orchard9/rdev/pkg/api"
)
// MergeFeatureRequest is the request body for merging a feature.
type MergeFeatureRequest struct {
Strategy string `json:"strategy,omitempty"`
}
// MergeFeature merges a feature branch after all gates pass.
// POST /projects/{id}/sdlc/features/{slug}/merge
func (h *SDLCHandler) MergeFeature(w http.ResponseWriter, r *http.Request) {
projectID := chi.URLParam(r, "id")
slug := chi.URLParam(r, "slug")
var req MergeFeatureRequest
if r.Body != nil && r.ContentLength > 0 {
if err := api.DecodeJSON(r, &req); err != nil {
api.WriteBadRequest(w, r, "invalid request body")
return
}
}
strategy := req.Strategy
if strategy == "" {
strategy = "squash"
}
ctx, cancel := context.WithTimeout(r.Context(), TimeoutHeavyWrite)
defer cancel()
if err := h.sdlcService.MergeFeature(ctx, projectID, slug, strategy); err != nil {
writeSDLCError(w, r, err)
return
}
api.WriteSuccess(w, r, map[string]string{"status": "merged", "strategy": strategy})
}
// ArchiveFeature archives a released feature.
// POST /projects/{id}/sdlc/features/{slug}/archive
func (h *SDLCHandler) ArchiveFeature(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()
if err := h.sdlcService.ArchiveFeature(ctx, projectID, slug); err != nil {
writeSDLCError(w, r, err)
return
}
api.WriteSuccess(w, r, map[string]string{"status": "archived"})
}