diff --git a/pkg/cmd/pr/shared/survey.go b/pkg/cmd/pr/shared/survey.go index 86b8f9021..48f621619 100644 --- a/pkg/cmd/pr/shared/survey.go +++ b/pkg/cmd/pr/shared/survey.go @@ -244,22 +244,20 @@ func MetadataSurvey(p Prompt, io *iostreams.IOStreams, baseRepo ghrepo.Interface fmt.Fprintln(io.ErrOut, "warning: no assignable users") } } - var mqs []*survey.Question if isChosen("Labels") { if len(labels) > 0 { - mqs = append(mqs, &survey.Question{ - Name: "labels", - Prompt: &survey.MultiSelect{ - Message: "Labels", - Options: labels, - Default: state.Labels, - Filter: prompter.LatinMatchingFilter, - }, - }) + selected, err := p.MultiSelect("Labels", state.Labels, labels) + if err != nil { + return err + } + for _, i := range selected { + values.Labels = append(values.Labels, labels[i]) + } } else { fmt.Fprintln(io.ErrOut, "warning: no labels in the repository") } } + var mqs []*survey.Question if isChosen("Projects") { if len(projects) > 0 { mqs = append(mqs, &survey.Question{ diff --git a/pkg/cmd/pr/shared/survey_test.go b/pkg/cmd/pr/shared/survey_test.go index 790bbcd2e..91fbed6ee 100644 --- a/pkg/cmd/pr/shared/survey_test.go +++ b/pkg/cmd/pr/shared/survey_test.go @@ -55,6 +55,9 @@ func TestMetadataSurvey_selectAll(t *testing.T) { pm.RegisterMultiSelect("Assignees", []string{}, []string{"hubot", "monalisa"}, func(_ string, _, _ []string) ([]int, error) { return []int{0}, nil }) + pm.RegisterMultiSelect("Labels", []string{}, []string{"help wanted", "good first issue"}, func(_ string, _, _ []string) ([]int, error) { + return []int{1}, nil + }) //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber as, restoreAsk := prompt.InitAskStubber() @@ -62,10 +65,6 @@ func TestMetadataSurvey_selectAll(t *testing.T) { //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt as.Stub([]*prompt.QuestionStub{ - { - Name: "labels", - Value: []string{"good first issue"}, - }, { Name: "projects", Value: []string{"The road to 1.0"}, @@ -115,6 +114,9 @@ func TestMetadataSurvey_keepExisting(t *testing.T) { pm.RegisterMultiSelect("What would you like to add?", []string{}, []string{"Assignees", "Labels", "Projects", "Milestone"}, func(_ string, _, _ []string) ([]int, error) { return []int{1, 2}, nil }) + pm.RegisterMultiSelect("Labels", []string{}, []string{"help wanted", "good first issue"}, func(_ string, _, _ []string) ([]int, error) { + return []int{1}, nil + }) //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber as, restoreAsk := prompt.InitAskStubber() @@ -122,10 +124,6 @@ func TestMetadataSurvey_keepExisting(t *testing.T) { //nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt as.Stub([]*prompt.QuestionStub{ - { - Name: "labels", - Value: []string{"good first issue"}, - }, { Name: "projects", Value: []string{"The road to 1.0"},