diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2017-02-12 22:24:33 +0000 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2017-02-12 22:24:33 +0000 |
commit | ba4840c52becf73c2749c9ef0f2f09ed0b9d5c7f (patch) | |
tree | 61b839884d66c9dd8269e26117aa4e4c995ad119 /vendor/github.com/google/go-github/github/pulls.go | |
parent | 6e00d0000e54f21a4a393e67fd914bda4d394f4a (diff) |
Update dependencies
Diffstat (limited to 'vendor/github.com/google/go-github/github/pulls.go')
-rw-r--r-- | vendor/github.com/google/go-github/github/pulls.go | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/vendor/github.com/google/go-github/github/pulls.go b/vendor/github.com/google/go-github/github/pulls.go index 51c6ccb..d3a9ae8 100644 --- a/vendor/github.com/google/go-github/github/pulls.go +++ b/vendor/github.com/google/go-github/github/pulls.go @@ -107,13 +107,13 @@ func (s *PullRequestsService) List(owner string, repo string, opt *PullRequestLi return nil, nil, err } - pulls := new([]*PullRequest) - resp, err := s.client.Do(req, pulls) + var pulls []*PullRequest + resp, err := s.client.Do(req, &pulls) if err != nil { return nil, resp, err } - return *pulls, resp, err + return pulls, resp, nil } // Get a single pull request. @@ -132,7 +132,7 @@ func (s *PullRequestsService) Get(owner string, repo string, number int) (*PullR return nil, resp, err } - return pull, resp, err + return pull, resp, nil } // GetRaw gets raw (diff or patch) format of a pull request. @@ -158,7 +158,7 @@ func (s *PullRequestsService) GetRaw(owner string, repo string, number int, opt return "", resp, err } - return ret.String(), resp, err + return ret.String(), resp, nil } // NewPullRequest represents a new pull request to be created. @@ -186,15 +186,36 @@ func (s *PullRequestsService) Create(owner string, repo string, pull *NewPullReq return nil, resp, err } - return p, resp, err + return p, resp, nil +} + +type pullRequestUpdate struct { + Title *string `json:"title,omitempty"` + Body *string `json:"body,omitempty"` + State *string `json:"state,omitempty"` + Base *string `json:"base,omitempty"` } // Edit a pull request. // +// The following fields are editable: Title, Body, State, and Base.Ref. +// Base.Ref updates the base branch of the pull request. +// // GitHub API docs: https://developer.github.com/v3/pulls/#update-a-pull-request func (s *PullRequestsService) Edit(owner string, repo string, number int, pull *PullRequest) (*PullRequest, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d", owner, repo, number) - req, err := s.client.NewRequest("PATCH", u, pull) + + update := new(pullRequestUpdate) + if pull != nil { + update.Title = pull.Title + update.Body = pull.Body + update.State = pull.State + if pull.Base != nil { + update.Base = pull.Base.Ref + } + } + + req, err := s.client.NewRequest("PATCH", u, update) if err != nil { return nil, nil, err } @@ -205,7 +226,7 @@ func (s *PullRequestsService) Edit(owner string, repo string, number int, pull * return nil, resp, err } - return p, resp, err + return p, resp, nil } // ListCommits lists the commits in a pull request. @@ -223,13 +244,13 @@ func (s *PullRequestsService) ListCommits(owner string, repo string, number int, return nil, nil, err } - commits := new([]*RepositoryCommit) - resp, err := s.client.Do(req, commits) + var commits []*RepositoryCommit + resp, err := s.client.Do(req, &commits) if err != nil { return nil, resp, err } - return *commits, resp, err + return commits, resp, nil } // ListFiles lists the files in a pull request. @@ -247,13 +268,13 @@ func (s *PullRequestsService) ListFiles(owner string, repo string, number int, o return nil, nil, err } - commitFiles := new([]*CommitFile) - resp, err := s.client.Do(req, commitFiles) + var commitFiles []*CommitFile + resp, err := s.client.Do(req, &commitFiles) if err != nil { return nil, resp, err } - return *commitFiles, resp, err + return commitFiles, resp, nil } // IsMerged checks if a pull request has been merged. @@ -321,5 +342,5 @@ func (s *PullRequestsService) Merge(owner string, repo string, number int, commi return nil, resp, err } - return mergeResult, resp, err + return mergeResult, resp, nil } |