prompter for assignees

This commit is contained in:
Nate Smith 2023-08-17 15:45:04 -05:00
parent a2758d3c28
commit 9b7cc44c7f
2 changed files with 11 additions and 18 deletions

View file

@ -231,22 +231,20 @@ func MetadataSurvey(p Prompt, io *iostreams.IOStreams, baseRepo ghrepo.Interface
fmt.Fprintln(io.ErrOut, "warning: no available reviewers")
}
}
var mqs []*survey.Question
if isChosen("Assignees") {
if len(assignees) > 0 {
mqs = append(mqs, &survey.Question{
Name: "assignees",
Prompt: &survey.MultiSelect{
Message: "Assignees",
Options: assignees,
Default: state.Assignees,
Filter: prompter.LatinMatchingFilter,
},
})
selected, err := p.MultiSelect("Assignees", state.Assignees, assignees)
if err != nil {
return err
}
for _, i := range selected {
values.Assignees = append(values.Assignees, assignees[i])
}
} else {
fmt.Fprintln(io.ErrOut, "warning: no assignable users")
}
}
var mqs []*survey.Question
if isChosen("Labels") {
if len(labels) > 0 {
mqs = append(mqs, &survey.Question{

View file

@ -52,6 +52,9 @@ func TestMetadataSurvey_selectAll(t *testing.T) {
pm.RegisterMultiSelect("Reviewers", []string{}, []string{"hubot", "monalisa"}, func(_ string, _, _ []string) ([]int, error) {
return []int{1}, nil
})
pm.RegisterMultiSelect("Assignees", []string{}, []string{"hubot", "monalisa"}, func(_ string, _, _ []string) ([]int, error) {
return []int{0}, nil
})
//nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber
as, restoreAsk := prompt.InitAskStubber()
@ -59,14 +62,6 @@ func TestMetadataSurvey_selectAll(t *testing.T) {
//nolint:staticcheck // SA1019: as.Stub is deprecated: use StubPrompt
as.Stub([]*prompt.QuestionStub{
//{
// Name: "reviewers",
// Value: []string{"monalisa"},
//},
{
Name: "assignees",
Value: []string{"hubot"},
},
{
Name: "labels",
Value: []string{"good first issue"},