Replace all GitHub API and gh CLI dependencies with Forgejo SDK via pkg/forge. The bash dispatcher burned a week of credit in a day due to bugs — the jobrunner now talks directly to Forgejo. - Add forge client methods: CreateIssueComment, CloseIssue, MergePullRequest, SetPRDraft, ListPRReviews, GetCombinedStatus, DismissReview - Create ForgejoSource implementing JobSource (epic polling, checklist parsing, commit status via combined status API) - Rewrite all 5 handlers to accept *forge.Client instead of shelling out - Replace ResolveThreadsHandler with DismissReviewsHandler (Forgejo has no thread resolution API — dismiss stale REQUEST_CHANGES reviews instead) - Delete pkg/jobrunner/github/ and handlers/exec.go entirely - Update internal/core-ide/headless.go to wire Forgejo source and handlers - All 33 tests pass with mock Forgejo HTTP servers Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
35 lines
968 B
Go
35 lines
968 B
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/host-uk/core/pkg/forge"
|
|
)
|
|
|
|
// forgejoVersionResponse is the JSON response for /api/v1/version.
|
|
const forgejoVersionResponse = `{"version":"9.0.0"}`
|
|
|
|
// withVersion wraps an HTTP handler to also serve the Forgejo version endpoint
|
|
// that the SDK calls during NewClient initialization.
|
|
func withVersion(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
if strings.HasSuffix(r.URL.Path, "/version") {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
_, _ = w.Write([]byte(forgejoVersionResponse))
|
|
return
|
|
}
|
|
next.ServeHTTP(w, r)
|
|
})
|
|
}
|
|
|
|
// newTestForgeClient creates a forge.Client pointing at the given test server URL.
|
|
func newTestForgeClient(t *testing.T, url string) *forge.Client {
|
|
t.Helper()
|
|
client, err := forge.New(url, "test-token")
|
|
require.NoError(t, err)
|
|
return client
|
|
}
|