Interactive issue/pr posting: properly fetch assignees (#476)

Gitea 1.15.0 added a proper API for listing assignee candidates.
imho that release is old enough that tea can start using this without workarounds.

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/476
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
Norwin 2022-03-19 19:08:58 +08:00 committed by Lunny Xiao
parent d8f4273ed0
commit 16ba594a28
1 changed files with 6 additions and 8 deletions

View File

@ -65,7 +65,7 @@ func promptIssueProperties(login *config.Login, owner, repo string, o *gitea.Cre
}
// assignees
if o.Assignees, err = promptMultiSelect("Assignees:", selectables.Collaborators, "[other]"); err != nil {
if o.Assignees, err = promptMultiSelect("Assignees:", selectables.Assignees, "[other]"); err != nil {
return err
}
@ -99,7 +99,7 @@ func promptIssueProperties(login *config.Login, owner, repo string, o *gitea.Cre
type issueSelectables struct {
Repo *gitea.Repository
Collaborators []string
Assignees []string
MilestoneList []string
MilestoneMap map[string]int64
LabelList []string
@ -124,17 +124,15 @@ func fetchIssueSelectables(login *config.Login, owner, repo string, done chan is
return
}
// FIXME: this should ideally be ListAssignees(), https://github.com/go-gitea/gitea/issues/14856
colabs, _, err := c.ListCollaborators(owner, repo, gitea.ListCollaboratorsOptions{})
assignees, _, err := c.GetAssignees(owner, repo)
if err != nil {
r.Err = err
done <- r
return
}
r.Collaborators = make([]string, len(colabs)+1)
r.Collaborators[0] = login.User
for i, u := range colabs {
r.Collaborators[i+1] = u.UserName
r.Assignees = make([]string, len(assignees))
for i, u := range assignees {
r.Assignees[i] = u.UserName
}
milestones, _, err := c.ListRepoMilestones(owner, repo, gitea.ListMilestoneOption{})