From 315dafbf74b58464599ed27b7a327dd755312159 Mon Sep 17 00:00:00 2001 From: Kynan Ware <47394200+BagToad@users.noreply.github.com> Date: Tue, 12 May 2026 14:58:54 -0600 Subject: [PATCH] Drop client-side feature detection for issue relationships Let the API return its own "unsupported" error rather than gating the relationship mutations behind a client-side IssueRelationships check. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- pkg/cmd/issue/create/create.go | 10 ++---- pkg/cmd/issue/create/create_test.go | 52 ----------------------------- pkg/cmd/issue/edit/edit.go | 9 ++--- pkg/cmd/issue/edit/edit_test.go | 16 --------- 4 files changed, 4 insertions(+), 83 deletions(-) diff --git a/pkg/cmd/issue/create/create.go b/pkg/cmd/issue/create/create.go index 09643d4b7..4b57cdd05 100644 --- a/pkg/cmd/issue/create/create.go +++ b/pkg/cmd/issue/create/create.go @@ -423,14 +423,8 @@ func createRun(opts *CreateOptions) (err error) { return } - // TODO IssueRelationshipsCleanup - if issueFeatures.IssueRelationshipsSupported { - err = applyRelationships(apiClient, baseRepo, newIssue, opts) - if err != nil { - return - } - } else if len(opts.BlockedBy) > 0 || len(opts.Blocking) > 0 { - err = fmt.Errorf("issue relationships are not supported on this GitHub Enterprise Server version") + err = applyRelationships(apiClient, baseRepo, newIssue, opts) + if err != nil { return } diff --git a/pkg/cmd/issue/create/create_test.go b/pkg/cmd/issue/create/create_test.go index aefa0f7ad..603bb7350 100644 --- a/pkg/cmd/issue/create/create_test.go +++ b/pkg/cmd/issue/create/create_test.go @@ -941,58 +941,6 @@ func Test_createRun(t *testing.T) { wantsStdout: "https://github.com/OWNER/REPO/issues/123\n", wantsStderr: "\nCreating issue in OWNER/REPO\n\n", }, - { - name: "blocked-by unsupported on GHES", - opts: CreateOptions{ - Detector: &fd.DisabledDetectorMock{}, - Title: "blocked issue", - Body: "blocked body", - BlockedBy: []string{"200"}, - }, - httpStubs: func(_ *testing.T, r *httpmock.Registry) { - r.Register( - httpmock.GraphQL(`query IssueRepositoryInfo\b`), - httpmock.StringResponse(` - { "data": { "repository": { - "id": "REPOID", - "hasIssuesEnabled": true - } } }`)) - r.Register( - httpmock.GraphQL(`mutation IssueCreate\b`), - httpmock.StringResponse(` - { "data": { "createIssue": { "issue": { - "id": "ISSUE_ID_123", - "URL": "https://github.com/OWNER/REPO/issues/123" - } } } }`)) - }, - wantsErr: "issue relationships are not supported on this GitHub Enterprise Server version", - }, - { - name: "blocking unsupported on GHES", - opts: CreateOptions{ - Detector: &fd.DisabledDetectorMock{}, - Title: "blocking issue", - Body: "blocking body", - Blocking: []string{"300"}, - }, - httpStubs: func(_ *testing.T, r *httpmock.Registry) { - r.Register( - httpmock.GraphQL(`query IssueRepositoryInfo\b`), - httpmock.StringResponse(` - { "data": { "repository": { - "id": "REPOID", - "hasIssuesEnabled": true - } } }`)) - r.Register( - httpmock.GraphQL(`mutation IssueCreate\b`), - httpmock.StringResponse(` - { "data": { "createIssue": { "issue": { - "id": "ISSUE_ID_123", - "URL": "https://github.com/OWNER/REPO/issues/123" - } } } }`)) - }, - wantsErr: "issue relationships are not supported on this GitHub Enterprise Server version", - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/cmd/issue/edit/edit.go b/pkg/cmd/issue/edit/edit.go index 2523c3cff..4a02fa9eb 100644 --- a/pkg/cmd/issue/edit/edit.go +++ b/pkg/cmd/issue/edit/edit.go @@ -424,7 +424,7 @@ func editRun(opts *EditOptions) error { } // Relationship mutations - if err := applyEditRelationships(apiClient, baseRepo, issue, opts, issueFeatures); err != nil { + if err := applyEditRelationships(apiClient, baseRepo, issue, opts); err != nil { failedIssueChan <- fmt.Sprintf("failed to update relationships for %s: %s", issue.URL, err) return } @@ -529,18 +529,13 @@ func applyEditSubIssues(client *api.Client, baseRepo ghrepo.Interface, issue *ap return nil } -func applyEditRelationships(client *api.Client, baseRepo ghrepo.Interface, issue *api.Issue, opts *EditOptions, features fd.IssueFeatures) error { +func applyEditRelationships(client *api.Client, baseRepo ghrepo.Interface, issue *api.Issue, opts *EditOptions) error { hasRelationshipFlags := len(opts.AddBlockedBy) > 0 || len(opts.RemoveBlockedBy) > 0 || len(opts.AddBlocking) > 0 || len(opts.RemoveBlocking) > 0 if !hasRelationshipFlags { return nil } - // TODO IssueRelationshipsCleanup - if !features.IssueRelationshipsSupported { - return fmt.Errorf("issue relationships are not supported on this GitHub Enterprise Server version") - } - hostname := baseRepo.RepoHost() for _, ref := range opts.AddBlockedBy { diff --git a/pkg/cmd/issue/edit/edit_test.go b/pkg/cmd/issue/edit/edit_test.go index f5811927e..4b8999d9f 100644 --- a/pkg/cmd/issue/edit/edit_test.go +++ b/pkg/cmd/issue/edit/edit_test.go @@ -1227,22 +1227,6 @@ func Test_editRun(t *testing.T) { }, stdout: "https://github.com/OWNER/REPO/issue/123\n", }, - { - name: "relationships unsupported on GHES", - input: &EditOptions{ - Detector: &fd.DisabledDetectorMock{}, - IssueNumbers: []int{123}, - Interactive: false, - AddBlockedBy: []string{"200"}, - FetchOptions: func(_ *api.Client, _ ghrepo.Interface, _ *prShared.Editable, _ gh.ProjectsV1Support) error { - return nil - }, - }, - httpStubs: func(t *testing.T, reg *httpmock.Registry) { - mockIssueGet(t, reg) - }, - wantErr: true, - }, { name: "batch edit type", input: &EditOptions{