fix(delvh): loop milestones and choose more likely options first
Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
parent
87dd95d961
commit
5b87d1331c
|
@ -162,19 +162,31 @@ func (gh *GitHub) initClient(ctx context.Context) {
|
||||||
|
|
||||||
func (gh *GitHub) milestoneNum(ctx context.Context) (int, error) {
|
func (gh *GitHub) milestoneNum(ctx context.Context) (int, error) {
|
||||||
owner, repo := gh.OwnerRepo()
|
owner, repo := gh.OwnerRepo()
|
||||||
milestones, _, err := gh.client.Issues.ListMilestones(ctx, owner, repo, &github.MilestoneListOptions{
|
p := 1
|
||||||
State: "all",
|
perPage := 100
|
||||||
ListOptions: github.ListOptions{
|
for {
|
||||||
PerPage: 100,
|
milestones, _, err := gh.client.Issues.ListMilestones(ctx, owner, repo, &github.MilestoneListOptions{
|
||||||
},
|
State: "all",
|
||||||
})
|
ListOptions: github.ListOptions{
|
||||||
if err != nil {
|
Page: p,
|
||||||
return 0, err
|
PerPage: perPage,
|
||||||
}
|
},
|
||||||
|
Sort: "due_on",
|
||||||
|
Direction: "desc",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
p++
|
||||||
|
|
||||||
for _, milestone := range milestones {
|
for _, milestone := range milestones {
|
||||||
if strings.EqualFold(milestone.GetTitle(), gh.Milestone) {
|
if strings.EqualFold(milestone.GetTitle(), gh.Milestone) {
|
||||||
return milestone.GetNumber(), nil
|
return milestone.GetNumber(), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(milestones) != perPage {
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue