diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2018-06-12 09:28:40 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2018-06-12 09:32:15 +0200 |
commit | c5ade44ba222c613b02db33e0ca6082d320aaf30 (patch) | |
tree | 3b88e6a1b8790db9aafe9d704ad6966433eedbe0 | |
download | aports-ghpr-c5ade44ba222c613b02db33e0ca6082d320aaf30.tar.bz2 aports-ghpr-c5ade44ba222c613b02db33e0ca6082d320aaf30.tar.xz |
initial import
-rw-r--r-- | LICENSE | 15 | ||||
-rw-r--r-- | Makefile | 13 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | aports-ghpr.go | 58 |
4 files changed, 90 insertions, 0 deletions
@@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2018, Natanael Copa <ncopa@alpinleinux.org> + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..16822da --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ + +prog = aports-ghpr +prefix = /usr/local +bindir = $(prefix)/bin + +$(prog): $(prog).go + go build -v $^ + +install: $(prog) + install -Dm755 $(prog) $(DESTDIR)$(bindir)/$(prog) + +clean: + rm -f $(prog) diff --git a/README.md b/README.md new file mode 100644 index 0000000..fac9766 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# aports-ghpr + +Tool to search github pull requests for aports + 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 + } +} |