prompter for assignees
This commit is contained in:
parent
a2758d3c28
commit
9b7cc44c7f
2 changed files with 11 additions and 18 deletions
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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"},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue