Skip to content

Commit e373ad6

Browse files
committed
Pass ProjectsV1Support to FetchOptions functions
Update FetchOptions and related function signatures to accept a ProjectsV1Support parameter, enabling conditional logic based on project support. This change improves flexibility for handling project fields in issue and PR editing flows.
1 parent e627f01 commit e373ad6

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

pkg/cmd/issue/edit/edit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type EditOptions struct {
3030
DetermineEditor func() (string, error)
3131
FieldsToEditSurvey func(prShared.EditPrompter, *prShared.Editable) error
3232
EditFieldsSurvey func(prShared.EditPrompter, *prShared.Editable, string) error
33-
FetchOptions func(*api.Client, ghrepo.Interface, *prShared.Editable) error
33+
FetchOptions func(*api.Client, ghrepo.Interface, *prShared.Editable, gh.ProjectsV1Support) error
3434

3535
IssueNumbers []int
3636
Interactive bool
@@ -248,7 +248,7 @@ func editRun(opts *EditOptions) error {
248248
// Fetch editable shared fields once for all issues.
249249
apiClient := api.NewClientFromHTTP(httpClient)
250250
opts.IO.StartProgressIndicatorWithLabel("Fetching repository information")
251-
err = opts.FetchOptions(apiClient, baseRepo, &editable)
251+
err = opts.FetchOptions(apiClient, baseRepo, &editable, opts.Detector.ProjectsV1())
252252
opts.IO.StopProgressIndicator()
253253
if err != nil {
254254
return err

pkg/cmd/pr/edit/edit.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ func editRun(opts *EditOptions) error {
293293
apiClient := api.NewClientFromHTTP(httpClient)
294294

295295
opts.IO.StartProgressIndicator()
296-
err = opts.Fetcher.EditableOptionsFetch(apiClient, repo, &editable)
296+
err = opts.Fetcher.EditableOptionsFetch(apiClient, repo, &editable, opts.Detector.ProjectsV1())
297297
opts.IO.StopProgressIndicator()
298298
if err != nil {
299299
return err
@@ -398,13 +398,13 @@ func (s surveyor) EditFields(editable *shared.Editable, editorCmd string) error
398398
}
399399

400400
type EditableOptionsFetcher interface {
401-
EditableOptionsFetch(*api.Client, ghrepo.Interface, *shared.Editable) error
401+
EditableOptionsFetch(*api.Client, ghrepo.Interface, *shared.Editable, gh.ProjectsV1Support) error
402402
}
403403

404404
type fetcher struct{}
405405

406-
func (f fetcher) EditableOptionsFetch(client *api.Client, repo ghrepo.Interface, opts *shared.Editable) error {
407-
return shared.FetchOptions(client, repo, opts)
406+
func (f fetcher) EditableOptionsFetch(client *api.Client, repo ghrepo.Interface, opts *shared.Editable, projectsV1Support gh.ProjectsV1Support) error {
407+
return shared.FetchOptions(client, repo, opts, projectsV1Support)
408408
}
409409

410410
type EditorRetriever interface {

pkg/cmd/pr/shared/editable.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55

66
"github.com/cli/cli/v2/api"
7+
"github.com/cli/cli/v2/internal/gh"
78
"github.com/cli/cli/v2/internal/ghrepo"
89
"github.com/cli/cli/v2/pkg/set"
910
)
@@ -395,7 +396,7 @@ func FieldsToEditSurvey(p EditPrompter, editable *Editable) error {
395396
return nil
396397
}
397398

398-
func FetchOptions(client *api.Client, repo ghrepo.Interface, editable *Editable) error {
399+
func FetchOptions(client *api.Client, repo ghrepo.Interface, editable *Editable, projectV1Support gh.ProjectsV1Support) error {
399400
// Determine whether to fetch organization teams.
400401
// Interactive reviewer editing (Edited true, but no Add/Remove slices) still needs
401402
// team data for selection UI. For non-interactive flows, we never need to fetch teams.
@@ -413,7 +414,7 @@ func FetchOptions(client *api.Client, repo ghrepo.Interface, editable *Editable)
413414
Assignees: editable.Assignees.Edited,
414415
ActorAssignees: editable.Assignees.ActorAssignees,
415416
Labels: editable.Labels.Edited,
416-
ProjectsV1: editable.Projects.Edited,
417+
ProjectsV1: editable.Projects.Edited && projectV1Support == gh.ProjectsV1Supported,
417418
ProjectsV2: editable.Projects.Edited,
418419
Milestones: editable.Milestone.Edited,
419420
}

0 commit comments

Comments
 (0)