1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package main
import (
"context"
"fmt"
"os"
"log"
"path"
"strings"
"github.com/google/go-github/github"
)
func main() {
// TODO: parse options from command line
var aport string = ""
// if APKBUILD exists in current directory, then we limit the search
if _, err := os.Stat("APKBUILD"); err == nil {
dir,err := os.Getwd()
if err != nil {
log.Fatal(err)
}
aport = path.Base(dir)
fmt.Println("searching for: ", aport)
}
// TODO: allow set this in some config file
owner := "alpinelinux"
repo := "aports"
// TODO: allow set authentication
client := github.NewClient(nil)
ctx := context.Background()
opt := &github.PullRequestListOptions{
ListOptions: github.ListOptions{PerPage: 200},
}
for {
prs, resp, err := client.PullRequests.List(ctx, owner, repo, opt)
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.URL, *pr.Title)
}
if resp.NextPage == 0 {
break
}
opt.Page = resp.NextPage
}
}
|