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.
This commit is contained in:
Kynan Ware 2025-10-21 15:03:52 -06:00
parent e627f0132e
commit e373ad6c9f
3 changed files with 9 additions and 8 deletions

View file

@ -30,7 +30,7 @@ type EditOptions struct {
DetermineEditor func() (string, error)
FieldsToEditSurvey func(prShared.EditPrompter, *prShared.Editable) error
EditFieldsSurvey func(prShared.EditPrompter, *prShared.Editable, string) error
FetchOptions func(*api.Client, ghrepo.Interface, *prShared.Editable) error
FetchOptions func(*api.Client, ghrepo.Interface, *prShared.Editable, gh.ProjectsV1Support) error
IssueNumbers []int
Interactive bool
@ -248,7 +248,7 @@ func editRun(opts *EditOptions) error {
// Fetch editable shared fields once for all issues.
apiClient := api.NewClientFromHTTP(httpClient)
opts.IO.StartProgressIndicatorWithLabel("Fetching repository information")
err = opts.FetchOptions(apiClient, baseRepo, &editable)
err = opts.FetchOptions(apiClient, baseRepo, &editable, opts.Detector.ProjectsV1())
opts.IO.StopProgressIndicator()
if err != nil {
return err

View file

@ -293,7 +293,7 @@ func editRun(opts *EditOptions) error {
apiClient := api.NewClientFromHTTP(httpClient)
opts.IO.StartProgressIndicator()
err = opts.Fetcher.EditableOptionsFetch(apiClient, repo, &editable)
err = opts.Fetcher.EditableOptionsFetch(apiClient, repo, &editable, opts.Detector.ProjectsV1())
opts.IO.StopProgressIndicator()
if err != nil {
return err
@ -398,13 +398,13 @@ func (s surveyor) EditFields(editable *shared.Editable, editorCmd string) error
}
type EditableOptionsFetcher interface {
EditableOptionsFetch(*api.Client, ghrepo.Interface, *shared.Editable) error
EditableOptionsFetch(*api.Client, ghrepo.Interface, *shared.Editable, gh.ProjectsV1Support) error
}
type fetcher struct{}
func (f fetcher) EditableOptionsFetch(client *api.Client, repo ghrepo.Interface, opts *shared.Editable) error {
return shared.FetchOptions(client, repo, opts)
func (f fetcher) EditableOptionsFetch(client *api.Client, repo ghrepo.Interface, opts *shared.Editable, projectsV1Support gh.ProjectsV1Support) error {
return shared.FetchOptions(client, repo, opts, projectsV1Support)
}
type EditorRetriever interface {

View file

@ -4,6 +4,7 @@ import (
"fmt"
"github.com/cli/cli/v2/api"
"github.com/cli/cli/v2/internal/gh"
"github.com/cli/cli/v2/internal/ghrepo"
"github.com/cli/cli/v2/pkg/set"
)
@ -395,7 +396,7 @@ func FieldsToEditSurvey(p EditPrompter, editable *Editable) error {
return nil
}
func FetchOptions(client *api.Client, repo ghrepo.Interface, editable *Editable) error {
func FetchOptions(client *api.Client, repo ghrepo.Interface, editable *Editable, projectV1Support gh.ProjectsV1Support) error {
// Determine whether to fetch organization teams.
// Interactive reviewer editing (Edited true, but no Add/Remove slices) still needs
// 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)
Assignees: editable.Assignees.Edited,
ActorAssignees: editable.Assignees.ActorAssignees,
Labels: editable.Labels.Edited,
ProjectsV1: editable.Projects.Edited,
ProjectsV1: editable.Projects.Edited && projectV1Support == gh.ProjectsV1Supported,
ProjectsV2: editable.Projects.Edited,
Milestones: editable.Milestone.Edited,
}