Skip to content

Commit

Permalink
prompter for assignees
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate Smith committed Aug 17, 2023
1 parent a2758d3 commit 9b7cc44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
18 changes: 8 additions & 10 deletions pkg/cmd/pr/shared/survey.go
Expand Up @@ -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{
Expand Down
11 changes: 3 additions & 8 deletions pkg/cmd/pr/shared/survey_test.go
Expand Up @@ -52,21 +52,16 @@ 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()
defer restoreAsk()

//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"},
Expand Down

0 comments on commit 9b7cc44

Please sign in to comment.