forked from lunny/changelog
github: use ListByRepo instead of global Issue Search
This commit is contained in:
parent
07c0fc1414
commit
df18780b5a
@ -9,6 +9,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-github/v50/github"
|
||||
@ -38,15 +39,22 @@ func (gh *GitHub) Generate() (string, []Entry, error) {
|
||||
state = "closed"
|
||||
}
|
||||
|
||||
query := fmt.Sprintf(`repo:%s is:%s milestone:"%s"`, gh.Repo, state, gh.Milestone)
|
||||
repoParts := strings.SplitN(gh.Repo, "/", 2)
|
||||
if len(repoParts) != 2 {
|
||||
return "", nil, fmt.Errorf("repo: '%s' can not be split into repoOwner and repoName", gh.Repo)
|
||||
}
|
||||
|
||||
p := 1
|
||||
perPage := 100
|
||||
|
||||
for {
|
||||
result, _, err := client.Search.Issues(ctx, query, &github.SearchOptions{
|
||||
result, _, err := client.Issues.ListByRepo(ctx, "owner", "repo", &github.IssueListByRepoOptions{
|
||||
ListOptions: github.ListOptions{
|
||||
Page: p,
|
||||
PerPage: perPage,
|
||||
},
|
||||
State: state,
|
||||
Milestone: gh.Milestone,
|
||||
})
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
@ -55,7 +63,7 @@ func (gh *GitHub) Generate() (string, []Entry, error) {
|
||||
|
||||
isPull := !(gh.Issues)
|
||||
|
||||
for _, pr := range result.Issues {
|
||||
for _, pr := range result {
|
||||
if pr.IsPullRequest() == isPull {
|
||||
p := Entry{
|
||||
Title: CleanTitle(pr.GetTitle()),
|
||||
@ -74,7 +82,7 @@ func (gh *GitHub) Generate() (string, []Entry, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if len(result.Issues) != perPage {
|
||||
if len(result) != perPage {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user