From 16ba594a28e80dacfd05f66ff3dee621bb830561 Mon Sep 17 00:00:00 2001 From: Norwin Date: Sat, 19 Mar 2022 19:08:58 +0800 Subject: [PATCH] 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 Reviewed-on: https://gitea.com/gitea/tea/pulls/476 Reviewed-by: techknowlogick Reviewed-by: Lunny Xiao Co-authored-by: Norwin Co-committed-by: Norwin --- modules/interact/issue_create.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/modules/interact/issue_create.go b/modules/interact/issue_create.go index 4cdab29..ba1e0cb 100644 --- a/modules/interact/issue_create.go +++ b/modules/interact/issue_create.go @@ -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{})