aboutsummaryrefslogtreecommitdiffstats
path: root/aports-ghpr.go
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2018-06-12 09:28:40 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2018-06-12 09:32:15 +0200
commitc5ade44ba222c613b02db33e0ca6082d320aaf30 (patch)
tree3b88e6a1b8790db9aafe9d704ad6966433eedbe0 /aports-ghpr.go
downloadaports-ghpr-c5ade44ba222c613b02db33e0ca6082d320aaf30.tar.bz2
aports-ghpr-c5ade44ba222c613b02db33e0ca6082d320aaf30.tar.xz
initial import
Diffstat (limited to 'aports-ghpr.go')
-rw-r--r--aports-ghpr.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/aports-ghpr.go b/aports-ghpr.go
new file mode 100644
index 0000000..aefc6ec
--- /dev/null
+++ b/aports-ghpr.go
@@ -0,0 +1,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
+ }
+}