diff options
author | Sören Tempel <soeren+git@soeren-tempel.net> | 2018-07-25 18:30:15 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2018-07-26 12:22:21 +0200 |
commit | bbc89ecfd1554fd74b1e747caf37a63e5e1e0e46 (patch) | |
tree | 59c629c08078316cb4643ff36d693da476ed37df | |
parent | 9e8e65ccf0084ac44422a6b1e8a00aa501a86037 (diff) | |
download | aports-ghpr-bbc89ecfd1554fd74b1e747caf37a63e5e1e0e46.tar.bz2 aports-ghpr-bbc89ecfd1554fd74b1e747caf37a63e5e1e0e46.tar.xz |
Use the search API instead of manually filtering all PRsv0.2
Much faster and uses less requests.
-rw-r--r-- | aports-ghpr.go | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/aports-ghpr.go b/aports-ghpr.go index 1d5eaf0..67d6f94 100644 --- a/aports-ghpr.go +++ b/aports-ghpr.go @@ -8,7 +8,6 @@ import ( "log" "os" "path" - "strings" ) var ( @@ -56,16 +55,14 @@ func main() { ListOptions: github.ListOptions{PerPage: 200}, } for { - prs, resp, err := client.PullRequests.List(ctx, *owner, *repo, opt) + query := fmt.Sprintf("%s type:pr in:title is:open repo:%s/%s", aport, *owner, *repo) + + res, resp, err := client.Search.Issues(ctx, query, nil) if err != nil { log.Fatal(err) } - for _, pr := range prs { - if aport != "" && !strings.Contains(*pr.Title, aport) { - continue - } - - fmt.Println(*pr.Number, *pr.User.Login, *pr.HTMLURL, *pr.Title) + for _, issue := range res.Issues { + fmt.Println(*issue.Number, *issue.User.Login, *issue.HTMLURL, *issue.Title) } if resp.NextPage == 0 { break |