Browse Source

Add support for PullRequestReviewEvent webhook.

Fixes #450.
Closes #451.

Change-Id: Iebdd2bd35a8ddd1346b2268e4e837d6145e990dc
Parker Moore 9 years ago
committed by Glenn Lewis
parent
commit
511bc5f4a8
5 changed files with 46 additions and 0 deletions
  1. +2
    -0
      github/activity_events.go
  2. +20
    -0
      github/event_types.go
  3. +1
    -0
      github/messages.go
  4. +4
    -0
      github/messages_test.go
  5. +19
    -0
      github/pulls_reviews.go

+ 2
- 0
github/activity_events.go View File

@ -69,6 +69,8 @@ func (e *Event) Payload() (payload interface{}) {
payload = &PublicEvent{} payload = &PublicEvent{}
case "PullRequestEvent": case "PullRequestEvent":
payload = &PullRequestEvent{} payload = &PullRequestEvent{}
case "PullRequestReviewEvent":
payload = &PullRequestReviewEvent{}
case "PullRequestReviewCommentEvent": case "PullRequestReviewCommentEvent":
payload = &PullRequestReviewCommentEvent{} payload = &PullRequestReviewCommentEvent{}
case "PushEvent": case "PushEvent":


+ 20
- 0
github/event_types.go View File

@ -327,6 +327,26 @@ type PullRequestEvent struct {
Sender *User `json:"sender,omitempty"` Sender *User `json:"sender,omitempty"`
} }
// PullRequestReviewEvent is triggered when a review is submitted on a pull
// request.
// The Webhook event name is "pull_request_review".
//
// GitHub docs: https://developer.github.com/v3/activity/events/types/#pullrequestreviewevent
type PullRequestReviewEvent struct {
// Action is always "submitted".
Action *string `json:"action,omitempty"`
Review *PullRequestReview `json:"review,omitempty"`
PullRequest *PullRequest `json:"pull_request,omitempty"`
// The following fields are only populated by Webhook events.
Repo *Repository `json:"repository,omitempty"`
Sender *User `json:"sender,omitempty"`
// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Organization *Organization `json:"organization,omitempty"`
}
// PullRequestReviewCommentEvent is triggered when a comment is created on a // PullRequestReviewCommentEvent is triggered when a comment is created on a
// portion of the unified diff of a pull request. // portion of the unified diff of a pull request.
// The Webhook event name is "pull_request_review_comment". // The Webhook event name is "pull_request_review_comment".


+ 1
- 0
github/messages.go View File

@ -55,6 +55,7 @@ var (
"milestone": "MilestoneEvent", "milestone": "MilestoneEvent",
"page_build": "PageBuildEvent", "page_build": "PageBuildEvent",
"public": "PublicEvent", "public": "PublicEvent",
"pull_request_review": "PullRequestReviewEvent",
"pull_request_review_comment": "PullRequestReviewCommentEvent", "pull_request_review_comment": "PullRequestReviewCommentEvent",
"pull_request": "PullRequestEvent", "pull_request": "PullRequestEvent",
"push": "PushEvent", "push": "PushEvent",


+ 4
- 0
github/messages_test.go View File

@ -152,6 +152,10 @@ func TestParseWebHook(t *testing.T) {
payload: &PullRequestEvent{}, payload: &PullRequestEvent{},
messageType: "pull_request", messageType: "pull_request",
}, },
{
payload: &PullRequestReviewEvent{},
messageType: "pull_request_review",
},
{ {
payload: &PullRequestReviewCommentEvent{}, payload: &PullRequestReviewCommentEvent{},
messageType: "pull_request_review_comment", messageType: "pull_request_review_comment",


+ 19
- 0
github/pulls_reviews.go View File

@ -0,0 +1,19 @@
// Copyright 2016 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package github
import "time"
// PullRequestReview represents a review of a pull request.
type PullRequestReview struct {
ID *int `json:"id,omitempty"`
User *User `json:"user,omitempty"`
Body *string `json:"body,omitempty"`
SubmittedAt *time.Time `json:"submitted_at,omitempty"`
// State can be "approved", "rejected", or "commented".
State *string `json:"state,omitempty"`
}

Loading…
Cancel
Save