<pre style='margin:0'>
Zero King (l2dy) pushed a commit to branch master
in repository mpbot-github.
</pre>
<p><a href="https://github.com/macports/mpbot-github/commit/80c887b233492518c570dc7e6536d79b64bfcc79">https://github.com/macports/mpbot-github/commit/80c887b233492518c570dc7e6536d79b64bfcc79</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/master by this push:
<span style='display:block; white-space:pre;color:#404040;'> new 80c887b Add retry command
</span>80c887b is described below
<span style='display:block; white-space:pre;color:#808000;'>commit 80c887b233492518c570dc7e6536d79b64bfcc79
</span>Author: Zero King <l2dy@macports.org>
AuthorDate: Sat Jan 5 17:03:22 2019 +0000
<span style='display:block; white-space:pre;color:#404040;'> Add retry command
</span>---
pr/webhook/pull_request.go | 5 +++++
pr/webhook/pull_request_others.go | 29 +++++++++++++++++++++++++++++
pr/webhook/pull_request_test.go | 8 --------
pr/webhook/util.go | 9 +++++++++
4 files changed, 43 insertions(+), 8 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/pr/webhook/pull_request.go b/pr/webhook/pull_request.go
</span><span style='display:block; white-space:pre;color:#808080;'>index 1daf6ff..cc4e7b1 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/pr/webhook/pull_request.go
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/pr/webhook/pull_request.go
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -29,6 +29,11 @@ func (receiver *Receiver) handlePullRequest(body []byte) {
</span> log.Println(err)
return
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ receiver.processPullRequest(event)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+func (receiver *Receiver) processPullRequest(event *github.PullRequestEvent) {
</span> number := *event.Number
owner := *event.Repo.Owner.Login
repo := *event.Repo.Name
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/pr/webhook/pull_request_others.go b/pr/webhook/pull_request_others.go
</span><span style='display:block; white-space:pre;color:#808080;'>index 5f3ee66..e096ded 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/pr/webhook/pull_request_others.go
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/pr/webhook/pull_request_others.go
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -3,7 +3,9 @@ package webhook
</span> import (
"encoding/json"
"log"
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ "regexp"
</span> "strconv"
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ "strings"
</span>
"github.com/google/go-github/github"
)
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -41,6 +43,33 @@ func (receiver *Receiver) handleOtherPullRequestEvents(eventType string, body []
</span> return
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ receiver.membersLock.RLock()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ members := receiver.members
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ receiver.membersLock.RUnlock()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if members != nil {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ _, isMember := (*members)[*event.Sender.Login]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if isMember && strings.Contains(*event.Comment.Body, "@macportsbot") { // TODO: read bot user from ENV
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ body := *event.Comment.Body
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if botMentioned, _ := regexp.MatchString(`@macportsbot\s`, body); botMentioned {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if doRetry, _ := regexp.MatchString(`@macportsbot\s+retry`, body); doRetry { // TODO: test compile patterns
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ pr, err := receiver.githubClient.GetPullRequest(*event.Repo.Owner.Login, *event.Repo.Name, *event.Issue.Number)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if err != nil {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ log.Println(err)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ fakeEvent := &github.PullRequestEvent{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Action: ptrOfStr("opened"),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Number: event.Issue.Number,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Repo: event.Repo,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Sender: event.Issue.User,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ PullRequest: pr,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ receiver.processPullRequest(fakeEvent)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> number = *event.Issue.Number
sender = *event.Sender.Login
default:
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/pr/webhook/pull_request_test.go b/pr/webhook/pull_request_test.go
</span><span style='display:block; white-space:pre;color:#808080;'>index 83e517d..92bec4e 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/pr/webhook/pull_request_test.go
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/pr/webhook/pull_request_test.go
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -206,11 +206,3 @@ func (stub *stubDBHelper) SetPRProcessed(number int, processed bool) error {
</span> func (stub *stubDBHelper) SetPRPendingReview(number int, pendingReview bool) error {
return nil
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-func ptrOfStr(s string) *string {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return &s
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-func ptrOfInt(s int) *int {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return &s
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-}
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/pr/webhook/util.go b/pr/webhook/util.go
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 0000000..df3622e
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/pr/webhook/util.go
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,9 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+package webhook
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+func ptrOfStr(s string) *string {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return &s
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+func ptrOfInt(s int) *int {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return &s
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span></pre><pre style='margin:0'>
</pre>