aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/google/go-github/github/pulls_reviews.go
diff options
context:
space:
mode:
authorhaixunlu <luhaixun@gmail.com>2018-12-18 12:49:30 -0800
committer无闻 <u@gogs.io>2018-12-18 15:49:30 -0500
commit311df9c521f05cdca880152e73dbed47afb74cde (patch)
treef3b9159e6dc23e6659e1da5939ff7f09d7a32c16 /vendor/github.com/google/go-github/github/pulls_reviews.go
parentff93d9dbda5cebe90d86e4b7dfb2c6b8642970ce (diff)
auth: add new authentication source: GitHub, including GitHub Enterprise (#5340)
* Add new Authentication Source: GitHub, including GitHub Enterprise. * Add vendor dependencies.
Diffstat (limited to 'vendor/github.com/google/go-github/github/pulls_reviews.go')
-rw-r--r--vendor/github.com/google/go-github/github/pulls_reviews.go236
1 files changed, 236 insertions, 0 deletions
diff --git a/vendor/github.com/google/go-github/github/pulls_reviews.go b/vendor/github.com/google/go-github/github/pulls_reviews.go
new file mode 100644
index 00000000..57d3c635
--- /dev/null
+++ b/vendor/github.com/google/go-github/github/pulls_reviews.go
@@ -0,0 +1,236 @@
+// 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 (
+ "context"
+ "fmt"
+ "time"
+)
+
+// PullRequestReview represents a review of a pull request.
+type PullRequestReview struct {
+ ID *int64 `json:"id,omitempty"`
+ User *User `json:"user,omitempty"`
+ Body *string `json:"body,omitempty"`
+ SubmittedAt *time.Time `json:"submitted_at,omitempty"`
+ CommitID *string `json:"commit_id,omitempty"`
+ HTMLURL *string `json:"html_url,omitempty"`
+ PullRequestURL *string `json:"pull_request_url,omitempty"`
+ State *string `json:"state,omitempty"`
+}
+
+func (p PullRequestReview) String() string {
+ return Stringify(p)
+}
+
+// DraftReviewComment represents a comment part of the review.
+type DraftReviewComment struct {
+ Path *string `json:"path,omitempty"`
+ Position *int `json:"position,omitempty"`
+ Body *string `json:"body,omitempty"`
+}
+
+func (c DraftReviewComment) String() string {
+ return Stringify(c)
+}
+
+// PullRequestReviewRequest represents a request to create a review.
+type PullRequestReviewRequest struct {
+ CommitID *string `json:"commit_id,omitempty"`
+ Body *string `json:"body,omitempty"`
+ Event *string `json:"event,omitempty"`
+ Comments []*DraftReviewComment `json:"comments,omitempty"`
+}
+
+func (r PullRequestReviewRequest) String() string {
+ return Stringify(r)
+}
+
+// PullRequestReviewDismissalRequest represents a request to dismiss a review.
+type PullRequestReviewDismissalRequest struct {
+ Message *string `json:"message,omitempty"`
+}
+
+func (r PullRequestReviewDismissalRequest) String() string {
+ return Stringify(r)
+}
+
+// ListReviews lists all reviews on the specified pull request.
+//
+// TODO: Follow up with GitHub support about an issue with this method's
+// returned error format and remove this comment once it's fixed.
+// Read more about it here - https://github.com/google/go-github/issues/540
+//
+// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request
+func (s *PullRequestsService) ListReviews(ctx context.Context, owner, repo string, number int, opt *ListOptions) ([]*PullRequestReview, *Response, error) {
+ u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews", owner, repo, number)
+ u, err := addOptions(u, opt)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ req, err := s.client.NewRequest("GET", u, nil)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var reviews []*PullRequestReview
+ resp, err := s.client.Do(ctx, req, &reviews)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return reviews, resp, nil
+}
+
+// GetReview fetches the specified pull request review.
+//
+// TODO: Follow up with GitHub support about an issue with this method's
+// returned error format and remove this comment once it's fixed.
+// Read more about it here - https://github.com/google/go-github/issues/540
+//
+// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-review
+func (s *PullRequestsService) GetReview(ctx context.Context, owner, repo string, number int, reviewID int64) (*PullRequestReview, *Response, error) {
+ u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, reviewID)
+
+ req, err := s.client.NewRequest("GET", u, nil)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ review := new(PullRequestReview)
+ resp, err := s.client.Do(ctx, req, review)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return review, resp, nil
+}
+
+// DeletePendingReview deletes the specified pull request pending review.
+//
+// TODO: Follow up with GitHub support about an issue with this method's
+// returned error format and remove this comment once it's fixed.
+// Read more about it here - https://github.com/google/go-github/issues/540
+//
+// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#delete-a-pending-review
+func (s *PullRequestsService) DeletePendingReview(ctx context.Context, owner, repo string, number int, reviewID int64) (*PullRequestReview, *Response, error) {
+ u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, reviewID)
+
+ req, err := s.client.NewRequest("DELETE", u, nil)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ review := new(PullRequestReview)
+ resp, err := s.client.Do(ctx, req, review)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return review, resp, nil
+}
+
+// ListReviewComments lists all the comments for the specified review.
+//
+// TODO: Follow up with GitHub support about an issue with this method's
+// returned error format and remove this comment once it's fixed.
+// Read more about it here - https://github.com/google/go-github/issues/540
+//
+// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-comments-for-a-single-review
+func (s *PullRequestsService) ListReviewComments(ctx context.Context, owner, repo string, number int, reviewID int64, opt *ListOptions) ([]*PullRequestComment, *Response, error) {
+ u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/comments", owner, repo, number, reviewID)
+ u, err := addOptions(u, opt)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ req, err := s.client.NewRequest("GET", u, nil)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ var comments []*PullRequestComment
+ resp, err := s.client.Do(ctx, req, &comments)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return comments, resp, nil
+}
+
+// CreateReview creates a new review on the specified pull request.
+//
+// TODO: Follow up with GitHub support about an issue with this method's
+// returned error format and remove this comment once it's fixed.
+// Read more about it here - https://github.com/google/go-github/issues/540
+//
+// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review
+func (s *PullRequestsService) CreateReview(ctx context.Context, owner, repo string, number int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) {
+ u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews", owner, repo, number)
+
+ req, err := s.client.NewRequest("POST", u, review)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ r := new(PullRequestReview)
+ resp, err := s.client.Do(ctx, req, r)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return r, resp, nil
+}
+
+// SubmitReview submits a specified review on the specified pull request.
+//
+// TODO: Follow up with GitHub support about an issue with this method's
+// returned error format and remove this comment once it's fixed.
+// Read more about it here - https://github.com/google/go-github/issues/540
+//
+// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#submit-a-pull-request-review
+func (s *PullRequestsService) SubmitReview(ctx context.Context, owner, repo string, number int, reviewID int64, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) {
+ u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/events", owner, repo, number, reviewID)
+
+ req, err := s.client.NewRequest("POST", u, review)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ r := new(PullRequestReview)
+ resp, err := s.client.Do(ctx, req, r)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return r, resp, nil
+}
+
+// DismissReview dismisses a specified review on the specified pull request.
+//
+// TODO: Follow up with GitHub support about an issue with this method's
+// returned error format and remove this comment once it's fixed.
+// Read more about it here - https://github.com/google/go-github/issues/540
+//
+// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#dismiss-a-pull-request-review
+func (s *PullRequestsService) DismissReview(ctx context.Context, owner, repo string, number int, reviewID int64, review *PullRequestReviewDismissalRequest) (*PullRequestReview, *Response, error) {
+ u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/dismissals", owner, repo, number, reviewID)
+
+ req, err := s.client.NewRequest("PUT", u, review)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ r := new(PullRequestReview)
+ resp, err := s.client.Do(ctx, req, r)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return r, resp, nil
+}